forked from APIJSON/APIJSON-Demo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRediSQLClient.java
More file actions
196 lines (145 loc) · 7.25 KB
/
RediSQLClient.java
File metadata and controls
196 lines (145 loc) · 7.25 KB
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
package apijson.demo.redis;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisShardInfo;
import redis.clients.jedis.commands.ProtocolCommand;
import redis.clients.jedis.util.SafeEncoder;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLParameters;
import javax.net.ssl.SSLSocketFactory;
import java.lang.reflect.Array;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
public class RediSQLClient extends redis.clients.jedis.Jedis {
public RediSQLClient() { super(); }
public RediSQLClient(final String host) { super(host); }
public RediSQLClient(final HostAndPort hp) { super(hp); }
public RediSQLClient(String host, int port) {
super(host, port);
}
public RediSQLClient(String host, int port, boolean ssl) {
super(host, port, ssl);
}
public RediSQLClient(String host, int port, boolean ssl, SSLSocketFactory sslSocketFactory, SSLParameters sslParameters, HostnameVerifier hostnameVerifier) {
super(host, port, ssl, sslSocketFactory, sslParameters, hostnameVerifier);
}
public RediSQLClient(String host, int port, int timeout) {
super(host, port, timeout);
}
public RediSQLClient(String host, int port, int timeout, boolean ssl) {
super(host, port, timeout, ssl);
}
public RediSQLClient(String host, int port, int timeout, boolean ssl, SSLSocketFactory sslSocketFactory, SSLParameters sslParameters, HostnameVerifier hostnameVerifier) {
super(host, port, timeout, ssl, sslSocketFactory, sslParameters, hostnameVerifier);
}
public RediSQLClient(String host, int port, int connectionTimeout, int soTimeout) {
super(host, port, connectionTimeout, soTimeout);
}
public RediSQLClient(String host, int port, int connectionTimeout, int soTimeout, boolean ssl) {
super(host, port, connectionTimeout, soTimeout, ssl);
}
public RediSQLClient(String host, int port, int connectionTimeout, int soTimeout, boolean ssl, SSLSocketFactory sslSocketFactory, SSLParameters sslParameters, HostnameVerifier hostnameVerifier) {
super(host, port, connectionTimeout, soTimeout, ssl, sslSocketFactory, sslParameters, hostnameVerifier);
}
public RediSQLClient(JedisShardInfo shardInfo) {
super(shardInfo);
}
public RediSQLClient(URI uri) {
super(uri);
}
public RediSQLClient(URI uri, SSLSocketFactory sslSocketFactory, SSLParameters sslParameters, HostnameVerifier hostnameVerifier) {
super(uri, sslSocketFactory, sslParameters, hostnameVerifier);
}
public RediSQLClient(URI uri, int timeout) {
super(uri, timeout);
}
public RediSQLClient(URI uri, int timeout, SSLSocketFactory sslSocketFactory, SSLParameters sslParameters, HostnameVerifier hostnameVerifier) {
super(uri, timeout, sslSocketFactory, sslParameters, hostnameVerifier);
}
public RediSQLClient(URI uri, int connectionTimeout, int soTimeout) {
super(uri, connectionTimeout, soTimeout);
}
public RediSQLClient(URI uri, int connectionTimeout, int soTimeout, SSLSocketFactory sslSocketFactory, SSLParameters sslParameters, HostnameVerifier hostnameVerifier) {
super(uri, connectionTimeout, soTimeout, sslSocketFactory, sslParameters, hostnameVerifier);
}
private String ok_returns(RediSQLCommand.ModuleCommand cmd, String... args) {
client.sendCommand(cmd, args);
return client.getBulkReply();
}
private List<Object> list_returns(RediSQLCommand.ModuleCommand cmd, String... args) {
client.sendCommand(cmd, args);
return client.getObjectMultiBulkReply();
}
public String create_db(String db) {
return ok_returns(RediSQLCommand.ModuleCommand.CREATE_DB, db);
}
public String create_db(String db, String file_path) {
return ok_returns(RediSQLCommand.ModuleCommand.CREATE_DB, db, file_path);
}
public List<Object> exec(String db, String query) {
return list_returns(RediSQLCommand.ModuleCommand.EXEC, db, query);
}
public List<Object> exec_now(String db, String query) {
return list_returns(RediSQLCommand.ModuleCommand.EXEC_NOW, db, query);
}
public List<Object> query(String db, String query) {
return list_returns(RediSQLCommand.ModuleCommand.QUERY, db, query);
}
public List<Object> query_now(String db, String query) {
return list_returns(RediSQLCommand.ModuleCommand.QUERY_NOW, db, query);
}
public List<Object> query_into(String stream, String db, String query) {
return list_returns(RediSQLCommand.ModuleCommand.QUERY_INTO, stream, db, query);
}
public List<Object> query_into_now(String stream, String db, String query) {
return list_returns(RediSQLCommand.ModuleCommand.QUERY_INTO_NOW, stream, db, query);
}
public String create_statement(String db, String stmt_name, String stmt_query) {
return ok_returns(RediSQLCommand.ModuleCommand.CREATE_STATEMENT, db, stmt_name, stmt_query);
}
public String create_statement_now(String db, String stmt_name, String stmt_query) {
return ok_returns(RediSQLCommand.ModuleCommand.CREATE_STATEMENT_NOW, db, stmt_name, stmt_query);
}
public List<Object> exec_statement(String... args) {
return list_returns(RediSQLCommand.ModuleCommand.EXEC_STATEMENT, args);
}
public List<Object> exec_statement_now(String... args) {
return list_returns(RediSQLCommand.ModuleCommand.EXEC_STATEMENT_NOW, args);
}
public List<Object> query_statement(String... args) {
return list_returns(RediSQLCommand.ModuleCommand.QUERY_STATEMENT, args);
}
public List<Object> query_statement_now(String... args) {
return list_returns(RediSQLCommand.ModuleCommand.QUERY_STATEMENT_NOW, args);
}
public List<Object> query_statement_into(String... args) {
return list_returns(RediSQLCommand.ModuleCommand.QUERY_STATEMENT_INTO, args);
}
public List<Object> query_statement_into_now(String... args) {
return list_returns(RediSQLCommand.ModuleCommand.QUERY_STATEMENT_INTO_NOW, args);
}
public String delete_statement(String db, String stmt_name) {
return ok_returns(RediSQLCommand.ModuleCommand.DELETE_STATEMENT, db, stmt_name);
}
public String delete_statement_now(String db, String stmt_name) {
return ok_returns(RediSQLCommand.ModuleCommand.DELETE_STATEMENT_NOW, db, stmt_name);
}
public String update_statement(String db, String stmt_name, String stmt_query) {
return ok_returns(RediSQLCommand.ModuleCommand.UPDATE_STATEMENT, db, stmt_name, stmt_query);
}
public String update_statement_now(String db, String stmt_name, String stmt_query) {
return ok_returns(RediSQLCommand.ModuleCommand.UPDATE_STATEMENT_NOW, db, stmt_name, stmt_query);
}
public String copy(String db1, String db2) {
return ok_returns(RediSQLCommand.ModuleCommand.COPY, db1, db2);
}
public String copy_now(String db1, String db2) {
return ok_returns(RediSQLCommand.ModuleCommand.COPY_NOW, db1, db2);
}
public List<Object> statistics() {
return list_returns(RediSQLCommand.ModuleCommand.STATISTICS);
}
public String version(String db1, String db2) {
return ok_returns(RediSQLCommand.ModuleCommand.VERSION);
}
}