@@ -36,9 +36,19 @@ class ACL_CPP_API redis_set : virtual public redis_command
36
36
* 将被忽略;
37
37
* 1) 假如 key 不存在,则创建一个只包含 member 元素作成员的集合
38
38
* 2) 当 key 不是集合类型时,返回一个错误
39
+ * add one or more members to a set stored at a key
40
+ * 1) if the key doesn't exist, a new set by the key will be created,
41
+ * and add the members to the set
42
+ * 2) if the key exists and not a set's key, then error happened
39
43
* @param key {const char*} 集合对象的键
44
+ * the key of a set
40
45
* @param first_member {const char*} 第一个非 NULL 的成员
46
+ * the first member of a variable args which isn't NULL, the last
47
+ * arg of the args must be NULL indicating the end of args
41
48
* @return {int} 被添加到集合中的新元素的数量,不包括被忽略的元素
49
+ * the number of elements that were added to the set, not including
50
+ * all the elements already present into the set. -1 if error
51
+ * happened or it isn't a set stored by the key.
42
52
*/
43
53
int sadd (const char * key, const char * first_member, ...);
44
54
int sadd (const char * key, const std::vector<const char *>& memsbers);
@@ -49,49 +59,93 @@ class ACL_CPP_API redis_set : virtual public redis_command
49
59
50
60
/* *
51
61
* 从集合对象中随机移除并返回某个成员
62
+ * remove and get one member from the set
52
63
* @param key {const char*} 集合对象的键
64
+ * the key of the set
53
65
* @param buf {string&} 存储被移除的成员
66
+ * store the member removed from the set
54
67
* @return {bool} 当 key 不存在或 key 是空集时返回 false
68
+ * true if one member has been removed and got, false if the key
69
+ * doesn't exist or it isn't a set stored at the key.
55
70
*/
56
71
bool spop (const char * key, string& buf);
57
72
58
73
/* *
59
74
* 获得集合对象中成员的数量
75
+ * get the number of members in a set stored at the key
60
76
* @param key {const char*} 集合对象的键
77
+ * the key of the set
61
78
* @return {int} 返回该集合对象中成员数量,含义如下:
79
+ * return int value as below:
62
80
* -1:出错或非集合对象
81
+ * error or it's not a set by the key
63
82
* 0:成员数量为空或该 key 不存在
83
+ * the set is empty or the key doesn't exist
64
84
* >0:成员数量非空
85
+ * the number of members in the set
65
86
*/
66
87
int scard (const char * key);
67
88
68
89
/* *
69
90
* 返回集合 key 中的所有成员
91
+ * get all the members in a set stored at a key
70
92
* @param key {const char*} 集合对象的键值
93
+ * the key of the set
71
94
* @param members {std::vector<string>*} 非空时存储结果集
95
+ * if not NULL, it will store the members.
72
96
* @return {int} 结果集数量,返回 -1 表示出错或有一个 key 非集合对象
97
+ * the number of elements got, -1 if error happened or it't not
98
+ * a set by the key.
99
+ *
73
100
* 操作成功后可以通过以下任一方式获得数据
74
- * 1、基类方法 get_value 获得指定下标的元素数据
75
- * 2、基类方法 get_child 获得指定下标的元素对象(redis_result),然后再通过
101
+ * if successul, one of below ways can be used to get the result:
102
+ * 1、在调用方法中传入非空的存储结果对象的地址
103
+ * input the no-NULL result parameter when call hmget, when
104
+ * success, the result will store the values of the given fileds
105
+ *
106
+ * 2、基类方法 get_value 获得指定下标的元素数据
107
+ * call redis_command::result_value with the specified subscript
108
+ *
109
+ * 3、基类方法 get_child 获得指定下标的元素对象(redis_result),然后再通过
76
110
* redis_result::argv_to_string 方法获得元素数据
77
- * 3、基类方法 get_result 方法取得总结果集对象 redis_result,然后再通过
111
+ * call redis_command::result_child with specified subscript to
112
+ * get redis_result object, then call redis_result::argv_to_string
113
+ * with above result to get the values of the give fileds
114
+ *
115
+ * 4、基类方法 get_result 方法取得总结果集对象 redis_result,然后再通过
78
116
* redis_result::get_child 获得一个元素对象,然后再通过方式 2 中指定
79
117
* 的方法获得该元素的数据
80
- * 4、基类方法 get_children 获得结果元素数组对象,再通过 redis_result 中
118
+ * call redis_command::get_result with the specified subscript to
119
+ * get redis_result object, and use redis_result::get_child to
120
+ * get one result object, then call redis_result::argv_to_string
121
+ * to get the value of one filed.
122
+ *
123
+ * 5、基类方法 get_children 获得结果元素数组对象,再通过 redis_result 中
81
124
* 的方法 argv_to_string 从每一个元素对象中获得元素数据
82
- * 5、在调用方法中传入非空的存储结果对象的地址
125
+ * use redis_command::get_children to get the redis_result array,
126
+ * then use redis_result::argv_to_string to get every value of
127
+ * the given fileds
83
128
*/
84
129
int smembers (const char * key, std::vector<string>* members);
85
130
86
131
/* *
87
132
* 将 member 元素从 src 集合移动到 dst 集合
133
+ * move a member from one set to another
88
134
* @param src {const char*} 源集合对象的键值
135
+ * the source key of a set
89
136
* @param dst {const char*} 目标集合对象的键值
137
+ * the destination key of a set
90
138
* @param member {const char*} 源集合对象的成员
139
+ * the member in the source set
91
140
* @return {int} 返回值含义如下:
141
+ * return int value as below:
92
142
* -1:出错或源/目标对象有一个非集合对象
143
+ * error happened, or one of source and destination isn't a set
93
144
* 0:源对象不存在或成员在源对象中不存在
145
+ * the source set or the member doesn't exist
94
146
* 1:成功从源对象中将一个成员移动至目标对象中
147
+ * move successfully the member from source set to
148
+ * the destination set
95
149
*/
96
150
int smove (const char * src, const char * dst, const char * member);
97
151
int smove (const char * src, const char * dst, const string& member);
@@ -100,19 +154,45 @@ class ACL_CPP_API redis_set : virtual public redis_command
100
154
101
155
/* *
102
156
* 返回一个集合的全部成员,该集合是所有给定集合之间的差集
157
+ * return the members of the set resulting from the difference
158
+ * between the first set and all the successive sets.
103
159
* @param members {std::vector<string>*} 非空时存储结果集
160
+ * if not NULL, it will store the members.
104
161
* @param first_key {const char*} 第一个非空的集合对象 key
162
+ * the key of the first set in a variable sets list, the last one
163
+ * must be NULL indicating the end of the sets list.
105
164
* @return {int} 结果集数量,返回 -1 表示出错或有一个 key 非集合对象
165
+ * the number of elements got, -1 if error happened or it't not
166
+ * a set by the key.
106
167
* 操作成功后可以通过以下任一方式获得数据
107
- * 1、基类方法 get_value 获得指定下标的元素数据
108
- * 2、基类方法 get_child 获得指定下标的元素对象(redis_result),然后再通过
168
+ * if successul, one of below ways can be used to get the result:
169
+ * 1、在调用方法中传入非空的存储结果对象的地址
170
+ * input the no-NULL result parameter when call hmget, when
171
+ * success, the result will store the values of the given fileds
172
+ *
173
+ * 2、基类方法 get_value 获得指定下标的元素数据
174
+ * call redis_command::result_value with the specified subscript
175
+ *
176
+ * 3、基类方法 get_child 获得指定下标的元素对象(redis_result),然后再通过
109
177
* redis_result::argv_to_string 方法获得元素数据
110
- * 3、基类方法 get_result 方法取得总结果集对象 redis_result,然后再通过
178
+ * call redis_command::result_child with specified subscript to
179
+ * get redis_result object, then call redis_result::argv_to_string
180
+ * with above result to get the values of the give fileds
181
+ *
182
+ * 4、基类方法 get_result 方法取得总结果集对象 redis_result,然后再通过
111
183
* redis_result::get_child 获得一个元素对象,然后再通过方式 2 中指定
112
184
* 的方法获得该元素的数据
113
- * 4、基类方法 get_children 获得结果元素数组对象,再通过 redis_result 中
185
+ * call redis_command::get_result with the specified subscript to
186
+ * get redis_result object, and use redis_result::get_child to
187
+ * get one result object, then call redis_result::argv_to_string
188
+ * to get the value of one filed.
189
+ *
190
+ * 5、基类方法 get_children 获得结果元素数组对象,再通过 redis_result 中
114
191
* 的方法 argv_to_string 从每一个元素对象中获得元素数据
115
- * 5、在调用方法中传入非空的存储结果对象的地址
192
+ * use redis_command::get_children to get the redis_result array,
193
+ * then use redis_result::argv_to_string to get every value of
194
+ * the given fileds
195
+
116
196
*/
117
197
int sdiff (std::vector<string>* members, const char * first_key, ...);
118
198
int sdiff (const std::vector<const char *>& keys,
@@ -122,9 +202,16 @@ class ACL_CPP_API redis_set : virtual public redis_command
122
202
123
203
/* *
124
204
* 返回一个集合的全部成员,该集合是所有给定集合的交集
205
+ * return the members of a set resulting from the intersection of
206
+ * all the give sets.
125
207
* @param members {std::vector<string>*} 非空时存储结果集
208
+ * if not NULL, it will store the result
126
209
* @param first_key {const char*} 第一个集合对象 key(非NULL)
210
+ * the key of the first set in a variable set list, which isn't NULL,
211
+ * the last one must be NULL in the set list.
127
212
* @return {int} 结果集数量,返回 -1 表示出错或有一个 key 非集合对象
213
+ * return the number of the members, -1 if error happened or
214
+ * it't not a set by the key.
128
215
*/
129
216
int sinter (std::vector<string>* members, const char * first_key, ...);
130
217
int sinter (const std::vector<const char *>& keys,
@@ -134,9 +221,16 @@ class ACL_CPP_API redis_set : virtual public redis_command
134
221
135
222
/* *
136
223
* 返回一个集合的全部成员,该集合是所有给定集合的并集
224
+ * return the members of a set resulting from the union of all the
225
+ * given sets.
137
226
* @param members {std::vector<string>*} 非空时存储结果集
227
+ * if not NULL, it will store the result
138
228
* @param first_key {const char*} 第一个集合对象 key(非NULL)
229
+ * the key of the first set in a variable set list, which isn't NULL,
230
+ * and the last arg must be NULL indicating the end of the set list.
139
231
* @return {int} 结果集数量,返回 -1 表示出错或有一个 key 非集合对象
232
+ * return the number of members, -1 if error happened or it's not
233
+ * a set by the key.
140
234
*/
141
235
int sunion (std::vector<string>* members, const char * first_key, ...);
142
236
int sunion (const std::vector<const char *>& keys,
@@ -146,61 +240,99 @@ class ACL_CPP_API redis_set : virtual public redis_command
146
240
147
241
/* *
148
242
* 这个命令的作用和 SDIFF 类似,但它将结果保存到 dst 集合,而不是简单地返回结果集
243
+ * This command is equal to SDIFF, but instead of returning
244
+ * the resulting set, it is stored in destination.
149
245
* @param dst {const char*} 目标集合对象键值
246
+ * the key of the destination set
150
247
* @param first_key {const char*} 第一个非空的集合对象键值
248
+ * the key of the first set in a variable set list, which isn't NULL,
249
+ * and the last arg must be NULL indicating the end of the set list.
151
250
* @return {int} 结果集中的成员数量
251
+ * return the number of members, -1 if error happened or it's not
252
+ * a set by the key.
152
253
*/
153
254
int sdiffstore (const char * dst, const char * first_key, ...);
154
255
int sdiffstore (const char * dst, const std::vector<const char *>& keys);
155
256
int sdiffstore (const char * dst, const std::vector<string>& keys);
156
257
157
258
/* *
158
259
* 这个命令类似于 SINTER 命令,但它将结果保存到 dst 集合,而不是简单地返回结果集
260
+ * This command is equal to SINTER, but instead of returning
261
+ * the resulting set, it is stored in destination.
159
262
* @param dst {const char*} 目标集合对象键值
263
+ * the key of the destination set
160
264
* @param first_key {const char*} 第一个非空的集合对象键值
265
+ * the key of the first set in a variable set list, which isn't NULL,
266
+ * and the last arg must be NULL indicating the end of the set list.
161
267
* @return {int} 结果集中的成员数量
268
+ * return the number of members, -1 if error happened or it's not
269
+ * a set by the key.
162
270
*/
163
271
int sinterstore (const char * dst, const char * first_key, ...);
164
272
int sinterstore (const char * dst, const std::vector<const char *>& keys);
165
273
int sinterstore (const char * dst, const std::vector<string>& keys);
166
274
167
275
/* *
168
276
* 这个命令类似于 SUNION 命令,但它将结果保存到 dst 集合,而不是简单地返回结果集
277
+ * This command is equal to SUNION, but instead of returning
278
+ * the resulting set, it is stored in destination.
169
279
* @param dst {const char*} 目标集合对象键值
280
+ * the key of the destination set
170
281
* @param first_key {const char*} 第一个非空的集合对象键值
282
+ * the key of the first set in a variable set list, which isn't NULL,
283
+ * and the last arg must be NULL indicating the end of the set list.
171
284
* @return {int} 结果集中的成员数量
285
+ * return the number of members, -1 if error happened or it's not
286
+ * a set by the key.
172
287
*/
173
288
int sunionstore (const char * dst, const char * first_key, ...);
174
289
int sunionstore (const char * dst, const std::vector<const char *>& keys);
175
290
int sunionstore (const char * dst, const std::vector<string>& keys);
176
291
177
292
/* *
178
293
* 判断 member 元素是否集合 key 的成员
294
+ * determine if a given value is a member of a set
179
295
* @param key {const char*} 集合对象的键值
180
- * @param member {const char*} 集合对象中的一个成员元素
296
+ * the key of a set
297
+ * @param member {const char*} 给定值
298
+ * the given value
181
299
* @return {bool} 返回 true 表示是,否则可能是因为不是或出错或该 key 对象
182
300
* 非集合对象
301
+ * true if the given is a member of the set, false if it's not a
302
+ * member of the set, or error, or it's not a set by the key.
183
303
*/
184
304
bool sismember (const char * key, const char * member);
185
305
bool sismember (const char * key, const char * member, size_t len);
186
306
187
307
/* *
188
308
* 如果命令执行时,只提供了 key 参数,那么返回集合中的一个随机元素,如果还同时指定
189
309
* 了元素个数,则会返回一个不超过该个数限制的结果集
310
+ * get one or multiple memebers from a set
190
311
* @param key {const char*} 集合对象的键值
312
+ * the key of a set
191
313
* @param out 存储结果或结果集
314
+ * store the result
192
315
* @return {int} 结果的个数,为 -1 表示出错,0 表示没有成员
316
+ * the number of members, 0 if the set by the key is empty,
317
+ * -1 if error happened.
193
318
*/
194
319
int srandmember (const char * key, string& out);
195
320
int srandmember (const char * key, size_t n, std::vector<string>& out);
196
321
197
322
/* *
198
323
* 移除集合 key 中的一个或多个 member 元素,不存在的 member 元素会被忽略
324
+ * Remove the specified members from the set stored at key. if the
325
+ * member doesn't exist, it will be ignored.
199
326
* @param key {const char*} 集合对象的键值
327
+ * the key of the set
200
328
* @param first_member {const char*} 需要被移除的成员列表的第一个非 NULL成员,
201
329
* 在变参的输入中需要将最后一个变参写 NULL
330
+ * the first non-NULL member to be removed in a variable member list,
331
+ * and the last one must be NULL indicating the end of the list.
202
332
* @retur {int} 被移除的成员元素的个数,当出错或非集合对象时返回 -1;当 key 不
203
333
* 存在或成员不存在时返回 0
334
+ * the number of members be removed, 0 if the set is empty or the
335
+ * key doesn't exist, -1 if error happened or it's not a set by key
204
336
*/
205
337
int srem (const char * key, const char * first_member, ...);
206
338
int srem (const char * key, const std::vector<string>& members);
@@ -210,17 +342,27 @@ class ACL_CPP_API redis_set : virtual public redis_command
210
342
211
343
/* *
212
344
* 命令用于迭代当前数据库中的数据库键
345
+ * scan the members in a set stored at key
213
346
* @param key {const char*} 哈希键值
347
+ * the key of a set
214
348
* @param cursor {int} 游标值,开始遍历时该值写 0
349
+ * the cursor value, which is 0 at begin
215
350
* @param out {std::vector<string>&} 存储结果集,内部以追加方式将本次遍历
216
351
* 结果集合添加进该数组中,为防止因总结果集过大导致该数组溢出,用户可在调用本
217
352
* 函数前后清理该数组对象
353
+ * store result in appending mode.
218
354
* @param pattern {const char*} 匹配模式,glob 风格,非空时有效
355
+ * match pattern, effective only on no-NULL
219
356
* @param count {const size_t*} 限定的结果集数量,非空指针时有效
357
+ * the max count of one scan process, effective only on no-NULL
220
358
* @return {int} 下一个游标位置,含义如下:
359
+ * return the next cursor position, as below:
221
360
* 0:遍历结束
361
+ * scan finish
222
362
* -1: 出错
363
+ * some error happened
223
364
* >0: 游标的下一个位置
365
+ * the next cursor postion to scan
224
366
*/
225
367
int sscan (const char * key, int cursor, std::vector<string>& out,
226
368
const char * pattern = NULL , const size_t * count = NULL );
0 commit comments