-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathConnectionTest.java
112 lines (88 loc) · 3.62 KB
/
ConnectionTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package cn.mageek.client;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @author Mageek Chiu
* @date 2018/5/10 0010:20:51
*/
public class ConnectionTest {
private static final Logger logger = LoggerFactory.getLogger(ConnectionTest.class);
public static void main(String... arg) throws Exception {
// Connection connection = new Connection();
// connection.connect();
Client client = new Client();
client.connect("192.168.0.136","10102");
// logger.debug(client.set("192.168.0.136:10099","123456")+"");
// logger.debug(client.get("192.168.0.136:10099")+"");
// logger.debug(client.set("112","23")+"");
// logger.debug(client.setnx("112","2333323")+"");
// logger.debug(client.setnx("112","2333")+"");
// logger.debug(client.setnx("112","232323")+"");
// logger.debug(client.get("112")+"");
// logger.debug(client.set("nba","23")+"");
// logger.debug(client.set("nba rock","23")+"");
// logger.debug(client.del("1321")+"");
// logger.debug(client.keys("nba").toString());
// logger.debug(client.keys("*").toString());
// logger.debug(client.del("112")+"");
// logger.debug(client.expire("nba",5)+"");// 5秒过期
// logger.debug(client.get("nba")+"");
// Thread.sleep(6000);
// logger.debug(client.get("nba")+"");
logger.debug(client.incrby("nba",10)+"");
logger.debug(client.incr("nba")+"");
// logger.debug(client.append("112","a")+"");
// logger.debug(client.append("112","a")+"");
//
new Thread(() -> {
logger.debug(client.incrby("nba",3)+"");
logger.debug(client.incr("nba")+"");
logger.debug(client.decrby("nba",4)+"");
logger.debug(client.incr("nba")+"");
logger.debug(client.incr("nba")+"");
logger.debug(client.incrby("nba",2)+"");
// logger.debug(client.append("112","b")+"");
// logger.debug(client.append("112","b")+"");
// logger.debug(client.append("112","b")+"");
// logger.debug(client.append("112","b")+"");
logger.debug(client.incrby("nba",4)+"");
}).start();
//
logger.debug(client.incr("nba")+"");
logger.debug(client.decr("nba")+"");
logger.debug(client.decrby("nba",3)+"");
logger.debug(client.decr("nba")+"");
logger.debug(client.incrby("nba",6)+"");
logger.debug(client.decr("nba")+"");
// logger.debug(client.append("112","a")+"");
// logger.debug(client.append("112","a")+"");
// client.close();
// try(Client client = new Client("192.168.0.136","10102")){
// logger.debug(client.set("192.168.0.136:10099","123456")+"");
// logger.debug(client.get("192.168.0.136:10099")+"");
// logger.debug(client.set("112","23")+"");
// logger.debug(client.del("1321")+"");
// logger.debug(client.del("112")+"");
// }
}
@Test
public void SplitTest(){
// 结果都是2 所以末尾有没有分隔符都一样
String a = "aa\r\nbb";
logger.debug("{}",a.split("\r\n").length);//2
a = "aa\r\nbb\r\n";
logger.debug("{}",a.split("\r\n").length);//2
a = "aa";
logger.debug("{}",a.split("\r\n").length);//1
}
@Test
public void regexTest(){
String regex = "a";
Matcher matcher = Pattern.compile(regex).matcher("sssa");
logger.debug(String.valueOf(matcher.matches()));
}
}