client.create().forPath("/head", new byte[0]); client.delete().inBackground().forPath("/head"); client.create().withMode(CreateMode.EPHEMERAL_SEQUENTIAL).forPath("/head/child", new byte[0]); client.getData().watched().inBackground().forPath("/test");
127.0.0.1:6379> incr num (integer) 1 127.0.0.1:6379> get num "1" 127.0.0.1:6379> incr num (integer) 2 127.0.0.1:6379> get num "2" 127.0.0.1:6379>
如果不存在会设置初始值为0,然后+1
数字递减
1 2 3 4 5 6 7 8 9 10 11 12 13
127.0.0.1:6379> decr num (integer) 1 127.0.0.1:6379> get num "1" 127.0.0.1:6379> decr num (integer) 0 127.0.0.1:6379> get num "0" 127.0.0.1:6379> 127.0.0.1:6379> decr num (integer) -1 127.0.0.1:6379> get num "-1"
数字增加指定的值
1 2 3 4 5
127.0.0.1:6379> incrby num 5 (integer) 4 127.0.0.1:6379> incrby num 5 (integer) 9 127.0.0.1:6379>
数字减去指定的值
1 2 3 4 5 6 7
127.0.0.1:6379> decrby num 3 (integer) 6 127.0.0.1:6379> decrby num 3 (integer) 3 127.0.0.1:6379> decrby num 3 (integer) 0 127.0.0.1:6379>
拼接字符串
1 2 3 4
127.0.0.1:6379> append name laoli (integer) 13 127.0.0.1:6379> get name "zhangsanlaoli"
重命名KEY
1 2 3 4 5 6 7 8 9 10
127.0.0.1:6379> set a1 a1 OK 127.0.0.1:6379> get a1 "a1" 127.0.0.1:6379> rename a1 aa1 OK 127.0.0.1:6379> get a1 (nil) 127.0.0.1:6379> get aa1 "a1"
设置过期时间 单位秒
1 2 3 4 5 6 7 8
127.0.0.1:6379> get abc "abc" 127.0.0.1:6379> expire abc 10 (integer) 1 127.0.0.1:6379> get abc "abc" 127.0.0.1:6379> get abc (nil)
查看超时时间
1 2 3 4 5 6 7 8 9 10 11
127.0.0.1:6379> set abc abc OK 127.0.0.1:6379> get abc "abc" 127.0.0.1:6379> ttl abc (integer) -1 127.0.0.1:6379> expire abc 100 (integer) 1 127.0.0.1:6379> ttl abc (integer) 96 127.0.0.1:6379>
获取key存储的数据类型
1 2 3 4 5 6
127.0.0.1:6379> type abc string 127.0.0.1:6379> type mylist list 127.0.0.1:6379> type myset set
/** * 最合适的Y轴线条高度间距 */ private static final int bastYAxisLineHeightInterval = 26;
/** * X轴上默认的线与线之间的像素 */ public static final int DEFAULT_X_AXIS_LINE_INTERVAL = 70; /** * 默认的当前值文本宽度 */ private static final int defaultCurrentTextWidth = 50;
/** * 最少的Y轴线条数量 */ private static final int minYAxisLineCount = 3;
private static final long serialVersionUID = 1L;
/** * 图片 */ private BufferedImage bufferImage;
/** * 显示当前值的文本宽度 */ private int currentTextWidth = 50;
private MonitorPanelModel dataModel;
private SimpleDateFormat dateF = new SimpleDateFormat("HH:mm");
private void drawDefaultXAxis() { int graphWidth = getGraphWidth(); int graphHeight = getGraphHeight(); // 每隔一定的像素画一条竖线 graphics.setColor(gridLineColor);
for (int i = YTextWidth + xAxisLineInterval; i < YTextWidth + graphWidth; i += xAxisLineInterval) { graphics.drawLine(i, titleHeight, i, titleHeight + graphHeight); } }
private void drawDefaultYAxis() { // 每隔一定的像素画一条线 int graphWidth = getGraphWidth(); int graphHeight = getGraphHeight();
// 画横线 graphics.setColor(gridLineColor); for (int i = graphHeight; i - bastYAxisLineHeightInterval > 0; i -= bastYAxisLineHeightInterval) { int yPosition = i - bastYAxisLineHeightInterval + titleHeight; graphics.drawLine(YTextWidth, yPosition, YTextWidth + graphWidth, yPosition); } }
/** * 绘制曲线 */ private void drawGraph() { graphics.setColor(graphLineColor); List<Coordinate> coordinatelist = dataModel.getCoordinatelist(); int size = coordinatelist.size(); if (size < 2) { return; } int[] xPoints = new int[size]; int[] yPoints = new int[size];
for (int i = 0; i < size; i++) { xPoints[i] = getXPoint(coordinatelist.get(i).getxValue()); yPoints[i] = getYPoint(coordinatelist.get(i).getyValue()); }
graphics.drawPolyline(xPoints, yPoints, size);
// 画一个当前值 Font font = graphics.getFont(); FontMetrics fm = graphics.getFontMetrics(font); int descent = fm.getDescent(); graphics.setColor(fontColor); int _yPoint = yPoints[size - 1]; int graphWidth = getGraphWidth(); int _xPoint = YTextWidth + graphWidth + 1; long currentValue = coordinatelist.get(coordinatelist.size() - 1).getyValue(); String valueOf = String.valueOf(currentValue); graphics.drawString(valueOf, _xPoint, _yPoint - descent); graphics.drawLine(_xPoint, _yPoint, _xPoint + fm.stringWidth(valueOf), _yPoint); }
/** * <pre> * 画背景 * </pre> */ private void drawGraphBackgound() { int graphWidth = getGraphWidth(); int graphHeight = getGraphHeight();
// 填充指定的矩形。该矩形左边缘和右边缘分别位于 x 和 x + width - 1。上边缘和下边缘分别位于 y 和 y + height - // 1。得到的矩形覆盖 width 像素宽乘以 height 像素高的区域。使用图形上下文的当前颜色填充该矩形。 graphics.fillRect(YTextWidth, titleHeight, graphWidth, graphHeight);
graphics.setColor(gridLineColor); // 绘制指定矩形的边框。矩形的左边缘和右边缘分别位于 x 和 x + width。上边缘和下边缘分别位于 y 和 y + // height。使用图形上下文的当前颜色绘制该矩形。 graphics.drawRect(YTextWidth, titleHeight, graphWidth, graphHeight);
Font font = graphics.getFont(); FontMetrics fm = graphics.getFontMetrics(font); int ascent = fm.getAscent(); // int descent = fm.getDescent(); // int fHeight = fm.getHeight();
int graphHeight = getGraphHeight();
// 画X坐标 for (long l : xLine) { int xPoint = getXPoint(l);
public int getCurrentTextWidth() { return currentTextWidth; }
public boolean getDisplayLastValue() { return displayLastValue; }
public Color getFontColor() { return fontColor; }
public Color getGraphBackgroundColor() { return graphBackgroundColor; }
/** * 获取曲线图区域的高度 * * @return */ public int getGraphHeight() { if (bufferImage == null) { return 0; } return bufferImage.getHeight() - titleHeight - XTextHeight; }
public Color getGraphLineColor() { return graphLineColor; }
public String getGraphTitle() { return graphTitle; }
/** * 获取曲线图区域的宽度 * * @return */ public int getGraphWidth() { if (bufferImage == null) { return 0; } return bufferImage.getWidth() - YTextWidth - currentTextWidth; }
public Color getGridLineColor() { return gridLineColor; }
/** * <pre> * 获取值对应X点坐标 * </pre> * * @param value * @return */ private int getXPoint(long value) { Long minXCoords = dataModel.getMinXCoords(); long v = value - minXCoords; int x = (int) (v * xRatio); return x + YTextWidth; }
/** * <pre> * 获取值对应Y点坐标 * </pre> * * @param value * @return */ private int getYPoint(long value) { Long minYCoords = dataModel.getMinYCoords(); long v = value - minYCoords; int y = (int) (v * yRatio); int graphHeight = getGraphHeight(); return graphHeight - y + titleHeight; }
public boolean isDrawEmptyGraph() { return drawEmptyGraph; }
@Override public void monitorPanelChanged(MonitorPanelModelEvent e) { repaint(); }
@Override public void paint(Graphics g) { super.paint(g);
# For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
[mysqld] # # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M # # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0
# Recommended in standard MySQL setup sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES