iFun Engine API  1.0.0-b2601
Great Technology for Great Games
 All Classes Files Functions Variables Typedefs Macros
redis_client.h
Go to the documentation of this file.
1 // Copyright (C) 2017 iFunFactory Inc. All Rights Reserved.
2 //
3 // This work is confidential and proprietary to iFunFactory Inc. and
4 // must not be used, disclosed, copied, or distributed without the prior
5 // consent of iFunFactory Inc.
6 //
7 
10 #ifndef INCLUDE_FUNAPI_DATABASE_REDIS_CLIENT_H_
11 #define INCLUDE_FUNAPI_DATABASE_REDIS_CLIENT_H_
12 
13 #include <funapi/common/json.h>
14 #include <funapi/types.h>
15 
16 #include <string>
17 #include <vector>
18 
19 
20 namespace fun {
21 
22 class RedisClient {
23  public:
24  struct Result {
25  enum Type {
26  kError = 0,
27  kSuccess = 1,
28  kNil = 2,
29  };
30 
31  Result();
32 
33  Type type;
34  int error_code;
35  string error_desc;
36  };
37 
38  struct Reply {
39  enum Type {
40  kString = 1,
41  kArray = 2,
42  kInteger = 3,
43  kNil = 4,
44  kStatus = 5,
45  kError = 6
46  };
47 
48  DECLARE_CLASS_PTR(Reply);
49 
50  Type type;
51  int64_t integer;
52  string str;
53  std::vector<Ptr<Reply> > elements;
54  };
55 
56  enum CommandOption {
57  kNone = 0,
58 
59  kEX,
60  kPX,
61  kNX,
62  kXX,
63 
64  kAND,
65  kOR,
66  kXOR,
67  kNOT,
68 
69  kBEFORE,
70  kAFTER
71  };
72 
73  typedef std::vector<string> StringList;
74  typedef std::pair<string, string> StringPair;
75  typedef std::vector<StringPair> StringPairList;
76  typedef std::pair<string, double> StringDoublePair;
77  typedef std::vector<StringDoublePair> StringDoublePairList;
78 
79  typedef function<void(const Result &, const Ptr<Reply> &)> Callback;
80  typedef function<void(const Result &, int64_t)> IntegerCallback;
81  typedef function<void(const Result &, double)> DoubleCallback;
82  typedef function<void(const Result &, const string &)> StringCallback;
83  typedef function<void(const Result &, const StringList &)> StringListCallback;
84  typedef function<void(const Result &,
85  const StringPairList &)> StringPairListCallback;
86  typedef function<
87  void(const Result &,
88  const StringDoublePairList &)> StringDoublePairListCallback;
89 
90  typedef function<void(const string &/*channel*/,
91  const string &/*message*/)> SubCallback;
92  typedef function<void(const string &/*pattern*/,
93  const string &/*channel*/,
94  const string &/*message*/)> PSubCallback;
95 
96  typedef Uuid SerializationTag;
97  static const SerializationTag kDefaultSerializationTag;
98 
99  static Ptr<RedisClient> Create(const string &server_ip,
100  int server_port,
101  const string &auth_pass,
102  size_t connection_count,
103  bool invoke_as_event = true,
104  size_t database = 0);
105 
106  void Initialize();
107  void Finalize();
108 
109  void SetProfiling(bool is_on);
110  void DumpProfilingResult(Json *out);
111 
112  bool invoke_as_event() const;
113 
115  void Del(const string &key, const IntegerCallback &callback,
116  const SerializationTag &tag = kDefaultSerializationTag);
117  void Del(const StringList &keys, const IntegerCallback &callback,
118  const SerializationTag &tag = kDefaultSerializationTag);
119  void Exists(const string &key, const IntegerCallback &callback,
120  const SerializationTag &tag = kDefaultSerializationTag);
121  void Expire(const string &key, uint64_t seconds,
122  const IntegerCallback &callback,
123  const SerializationTag &tag = kDefaultSerializationTag);
124  void PExpire(const string &key, uint64_t milliseconds,
125  const IntegerCallback &callback,
126  const SerializationTag &tag = kDefaultSerializationTag);
127  void Persist(const string &key, const IntegerCallback &callback,
128  const SerializationTag &tag = kDefaultSerializationTag);
129  void TTL(const string &key, const IntegerCallback &callback,
130  const SerializationTag &tag = kDefaultSerializationTag);
131  void PTTL(const string &key, const IntegerCallback &callback,
132  const SerializationTag &tag = kDefaultSerializationTag);
133  void Rename(const string &key, const string &new_key,
134  const StringCallback &callback,
135  const SerializationTag &tag = kDefaultSerializationTag);
136 
137  Result DelSync(const string &key, int64_t *out);
138  Result DelSync(const StringList &keys, int64_t *out);
139  Result ExistsSync(const string &key, int64_t *out);
140  Result ExpireSync(const string &key, uint64_t seconds, int64_t *out);
141  Result PExpireSync(const string &key, uint64_t milliseconds, int64_t *out);
142  Result PersistSync(const string &key, int64_t *out);
143  Result TTLSync(const string &key, int64_t *out);
144  Result PTTLSync(const string &key, int64_t *out);
145  Result RenameSync(const string &key, const string &new_key, string *out);
146 
148  void Append(const string &key, const string &value,
149  const IntegerCallback &callback,
150  const SerializationTag &tag = kDefaultSerializationTag);
151  void Incr(const string &key, const IntegerCallback &callback,
152  const SerializationTag &tag = kDefaultSerializationTag);
153  void IncrBy(const string &key, int64_t increment,
154  const IntegerCallback &callback,
155  const SerializationTag &tag = kDefaultSerializationTag);
156  void IncrByFloat(const string &key, double increment,
157  const DoubleCallback &callback,
158  const SerializationTag &tag = kDefaultSerializationTag);
159  void Decr(const string &key, const IntegerCallback &callback,
160  const SerializationTag &tag = kDefaultSerializationTag);
161  void DecrBy(const string &key, int64_t decrement,
162  const IntegerCallback &callback,
163  const SerializationTag &tag = kDefaultSerializationTag);
164  void StrLen(const string &key, const IntegerCallback &callback,
165  const SerializationTag &tag = kDefaultSerializationTag);
166  void Get(const string &key, const StringCallback &callback,
167  const SerializationTag &tag = kDefaultSerializationTag);
168  void MGet(const StringList &keys, const StringListCallback &callback,
169  const SerializationTag &tag = kDefaultSerializationTag);
170  void GetRange(const string &key, int64_t start, int64_t end,
171  const StringCallback &callback,
172  const SerializationTag &tag = kDefaultSerializationTag);
173  void GetSet(const string &key, const string &value,
174  const StringCallback &callback,
175  const SerializationTag &tag = kDefaultSerializationTag);
176  void Set(const string &key, const string &value,
177  const StringCallback &callback,
178  const SerializationTag &tag = kDefaultSerializationTag);
179  void Set(const string &key, const string &value,
180  CommandOption ex_or_px, uint64_t time,
181  CommandOption nx_or_xx, const StringCallback &callback,
182  const SerializationTag &tag = kDefaultSerializationTag);
183  void SetEx(const string &key, uint64_t seconds, const string &value,
184  const StringCallback &callback,
185  const SerializationTag &tag = kDefaultSerializationTag);
186  void PSetEx(const string &key, uint64_t milliseconds,
187  const string &value, const StringCallback &callback,
188  const SerializationTag &tag = kDefaultSerializationTag);
189  void SetNx(const string &key, const string &value,
190  const IntegerCallback &callback,
191  const SerializationTag &tag = kDefaultSerializationTag);
192  void MSet(const StringPairList &key_values, const StringCallback &callback,
193  const SerializationTag &tag = kDefaultSerializationTag);
194  void MSetNx(const StringPairList &key_values,
195  const IntegerCallback &callback,
196  const SerializationTag &tag = kDefaultSerializationTag);
197  void BitCount(const string &key, const IntegerCallback &callback,
198  const SerializationTag &tag = kDefaultSerializationTag);
199  void BitCount(const string &key, int64_t start, int64_t end,
200  const IntegerCallback &callback,
201  const SerializationTag &tag = kDefaultSerializationTag);
202  void BitOp(CommandOption operation, const string &dest_key,
203  const StringList &keys, const IntegerCallback &callback,
204  const SerializationTag &tag = kDefaultSerializationTag);
205  void GetBit(const string &key, uint64_t offset,
206  const IntegerCallback &callback,
207  const SerializationTag &tag = kDefaultSerializationTag);
208  void SetBit(const string &key, uint64_t offset, bool value,
209  const IntegerCallback &callback,
210  const SerializationTag &tag = kDefaultSerializationTag);
211 
212  Result AppendSync(const string &key, const string &value, int64_t *out);
213  Result IncrSync(const string &key, int64_t *out);
214  Result IncrBySync(const string &key, int64_t increment, int64_t *out);
215  Result IncrByFloatSync(const string &key, double increment, double *out);
216  Result DecrSync(const string &key, int64_t *out);
217  Result DecrBySync(const string &key, int64_t decrement, int64_t *out);
218  Result StrLenSync(const string &key, int64_t *out);
219  Result GetSync(const string &key, string *out);
220  Result MGetSync(const StringList &keys, StringList *out);
221  Result GetRangeSync(const string &key, int64_t start, int64_t end,
222  string *out);
223  Result GetSetSync(const string &key, const string &value, string *out);
224  Result SetSync(const string &key, const string &value, string *out);
225  Result SetSync(const string &key, const string &value,
226  CommandOption ex_or_px, uint64_t time,
227  CommandOption nx_or_xx, string *out);
228  Result SetExSync(const string &key, uint64_t seconds, const string &value,
229  string *out);
230  Result PSetExSync(const string &key, uint64_t milliseconds,
231  const string &value, string *out);
232  Result SetNxSync(const string &key, const string &value, int64_t *out);
233  Result MSetSync(const StringPairList &key_values, string *out);
234  Result MSetNxSync(const StringPairList &key_values, int64_t *out);
235  Result BitCountSync(const string &key, int64_t *out);
236  Result BitCountSync(const string &key, int64_t start, int64_t end,
237  int64_t *out);
238  Result BitOpSync(CommandOption operation, const string &dest_key,
239  const StringList &keys, int64_t *out);
240  Result GetBitSync(const string &key, uint64_t offset, int64_t *out);
241  Result SetBitSync(const string &key, uint64_t offset, bool value,
242  int64_t *out);
243 
245  void HExists(const string &key, const string &field,
246  const IntegerCallback &callback,
247  const SerializationTag &tag = kDefaultSerializationTag);
248  void HKeys(const string &key, const StringListCallback &callback,
249  const SerializationTag &tag = kDefaultSerializationTag);
250  void HVals(const string &key, const StringListCallback &callback,
251  const SerializationTag &tag = kDefaultSerializationTag);
252  void HLen(const string &key, const IntegerCallback &callback,
253  const SerializationTag &tag = kDefaultSerializationTag);
254  void HIncrBy(const string &key, const string &field, int64_t increment,
255  const IntegerCallback &callback,
256  const SerializationTag &tag = kDefaultSerializationTag);
257  void HIncrByFloat(const string &key, const string &field,
258  double increment, const DoubleCallback &callback,
259  const SerializationTag &tag = kDefaultSerializationTag);
260  void HDel(const string &key, const string &field,
261  const IntegerCallback &callback,
262  const SerializationTag &tag = kDefaultSerializationTag);
263  void HDel(const string &key, const StringList &fields,
264  const IntegerCallback &callback,
265  const SerializationTag &tag = kDefaultSerializationTag);
266  void HGet(const string &key, const string &field,
267  const StringCallback &callback,
268  const SerializationTag &tag = kDefaultSerializationTag);
269  void HGetAll(const string &key, const StringPairListCallback &callback,
270  const SerializationTag &tag = kDefaultSerializationTag);
271  void HMGet(const string &key, const StringList &fields,
272  const StringListCallback &callback,
273  const SerializationTag &tag = kDefaultSerializationTag);
274  void HSet(const string &key, const string &field, const string &value,
275  const IntegerCallback &callback,
276  const SerializationTag &tag = kDefaultSerializationTag);
277  void HSetNx(const string &key, const string &field, const string &value,
278  const IntegerCallback &callback,
279  const SerializationTag &tag = kDefaultSerializationTag);
280  void HMSet(const string &key, const StringPairList &field_values,
281  const StringCallback &callback,
282  const SerializationTag &tag = kDefaultSerializationTag);
283 
284  Result HExistsSync(const string &key, const string &field, int64_t *out);
285  Result HKeysSync(const string &key, StringList *out);
286  Result HValsSync(const string &key, StringList *out);
287  Result HLenSync(const string &key, int64_t *out);
288  Result HIncrBySync(const string &key, const string &field,
289  int64_t increment, int64_t *out);
290  Result HIncrByFloatSync(const string &key, const string &field,
291  double increment, double *out);
292  Result HDelSync(const string &key, const string &field, int64_t *out);
293  Result HDelSync(const string &key, const StringList &fields, int64_t *out);
294  Result HGetSync(const string &key, const string &field, string *out);
295  Result HGetAllSync(const string &key, StringPairList *out);
296  Result HMGetSync(const string &key, const StringList &fields,
297  StringList *out);
298  Result HSetSync(const string &key, const string &field, const string &value,
299  int64_t *out);
300  Result HSetNxSync(const string &key, const string &field, const string &value,
301  int64_t *out);
302  Result HMSetSync(const string &key, const StringPairList &field_values,
303  string *out);
304 
306  void LLen(const string &key, const IntegerCallback &callback,
307  const SerializationTag &tag = kDefaultSerializationTag);
308  void LIndex(const string &key, int64_t index, const StringCallback &callback,
309  const SerializationTag &tag = kDefaultSerializationTag);
310  void LRange(const string &key, int64_t start, int64_t stop,
311  const StringListCallback &callback,
312  const SerializationTag &tag = kDefaultSerializationTag);
313  void LRem(const string &key, int64_t count, const string &value,
314  const IntegerCallback &callback,
315  const SerializationTag &tag = kDefaultSerializationTag);
316  void LTrim(const string &key, int64_t start, int64_t stop,
317  const StringCallback &callback,
318  const SerializationTag &tag = kDefaultSerializationTag);
319  void LPush(const string &key, const string &value,
320  const IntegerCallback &callback,
321  const SerializationTag &tag = kDefaultSerializationTag);
322  void LPush(const string &key, const StringList &values,
323  const IntegerCallback &callback,
324  const SerializationTag &tag = kDefaultSerializationTag);
325  void RPush(const string &key, const string &value,
326  const IntegerCallback &callback,
327  const SerializationTag &tag = kDefaultSerializationTag);
328  void RPush(const string &key, const StringList &values,
329  const IntegerCallback &callback,
330  const SerializationTag &tag = kDefaultSerializationTag);
331  void LPop(const string &key, const StringCallback &callback,
332  const SerializationTag &tag = kDefaultSerializationTag);
333  void RPop(const string &key, const StringCallback &callback,
334  const SerializationTag &tag = kDefaultSerializationTag);
335  void LInsert(const string &key, CommandOption before_or_after,
336  const string &pivot, const string &value,
337  const IntegerCallback &callback,
338  const SerializationTag &tag = kDefaultSerializationTag);
339  void LSet(const string &key, int64_t index, const string &value,
340  const StringCallback &callback,
341  const SerializationTag &tag = kDefaultSerializationTag);
342 
343  Result LLenSync(const string &key, int64_t *out);
344  Result LIndexSync(const string &key, int64_t index, string *out);
345  Result LRangeSync(const string &key, int64_t start, int64_t stop,
346  StringList *out);
347  Result LRemSync(const string &key, int64_t count, const string &value,
348  int64_t *out);
349  Result LTrimSync(const string &key, int64_t start, int64_t stop,
350  string *out);
351  Result LPushSync(const string &key, const string &value, int64_t *out);
352  Result LPushSync(const string &key, const StringList &values,
353  int64_t *out);
354  Result RPushSync(const string &key, const string &value, int64_t *out);
355  Result RPushSync(const string &key, const StringList &values, int64_t *out);
356  Result LPopSync(const string &key, string *out);
357  Result RPopSync(const string &key, string *out);
358  Result LInsertSync(const string &key, CommandOption before_or_after,
359  const string &pivot, const string &value, int64_t *out);
360  Result LSetSync(const string &key, int64_t index, const string &value,
361  string *out);
362 
364  void SCard(const string &key, const IntegerCallback &callback,
365  const SerializationTag &tag = kDefaultSerializationTag);
366  void SIsMember(const string &key, const string &member,
367  const IntegerCallback &callback,
368  const SerializationTag &tag = kDefaultSerializationTag);
369  void SMembers(const string &key, const StringListCallback &callback,
370  const SerializationTag &tag = kDefaultSerializationTag);
371  void SRandMember(const string &key, const StringCallback &callback,
372  const SerializationTag &tag = kDefaultSerializationTag);
373  void SRandMember(const string &key, int64_t count,
374  const StringListCallback &callback,
375  const SerializationTag &tag = kDefaultSerializationTag);
376  void SDiff(const StringList &keys, const StringListCallback &callback,
377  const SerializationTag &tag = kDefaultSerializationTag);
378  void SDiffStore(const string &destination, const StringList &keys,
379  const IntegerCallback &callback,
380  const SerializationTag &tag = kDefaultSerializationTag);
381  void SInter(const StringList &keys, const StringListCallback &callback,
382  const SerializationTag &tag = kDefaultSerializationTag);
383  void SInterStore(const string &destination, const StringList &keys,
384  const IntegerCallback &callback,
385  const SerializationTag &tag = kDefaultSerializationTag);
386  void SUnion(const StringList &keys, const StringListCallback &callback,
387  const SerializationTag &tag = kDefaultSerializationTag);
388  void SUnionStore(const string &destination, const StringList &keys,
389  const IntegerCallback &callback,
390  const SerializationTag &tag = kDefaultSerializationTag);
391  void SAdd(const string &key, const string &member,
392  const IntegerCallback &callback,
393  const SerializationTag &tag = kDefaultSerializationTag);
394  void SAdd(const string &key, const StringList &members,
395  const IntegerCallback &callback,
396  const SerializationTag &tag = kDefaultSerializationTag);
397  void SPop(const string &key, const StringCallback &callback,
398  const SerializationTag &tag = kDefaultSerializationTag);
399  void SRem(const string &key, const string &member,
400  const IntegerCallback &callback,
401  const SerializationTag &tag = kDefaultSerializationTag);
402  void SRem(const string &key, const StringList &members,
403  const IntegerCallback &callback,
404  const SerializationTag &tag = kDefaultSerializationTag);
405  void SMove(const string &source, const string &destination,
406  const string &member, const IntegerCallback &callback,
407  const SerializationTag &tag = kDefaultSerializationTag);
408 
409  Result SCardSync(const string &key, int64_t *out);
410  Result SIsMemberSync(const string &key, const string &member, int64_t *out);
411  Result SMembersSync(const string &key, StringList *out);
412  Result SRandMemberSync(const string &key, string *out);
413  Result SRandMemberSync(const string &key, int64_t count, StringList *out);
414  Result SDiffSync(const StringList &keys, StringList *out);
415  Result SDiffStoreSync(const string &destination, const StringList &keys,
416  int64_t *out);
417  Result SInterSync(const StringList &keys, StringList *out);
418  Result SInterStoreSync(const string &destination, const StringList &keys,
419  int64_t *out);
420  Result SUnionSync(const StringList &keys, StringList *out);
421  Result SUnionStoreSync(const string &destination, const StringList &keys,
422  int64_t *out);
423  Result SAddSync(const string &key, const string &member,
424  int64_t *out);
425  Result SAddSync(const string &key, const StringList &members,
426  int64_t *out);
427  Result SPopSync(const string &key, string *out);
428  Result SRemSync(const string &key, const string &member, int64_t *out);
429  Result SRemSync(const string &key, const StringList &members,
430  int64_t *out);
431  Result SMoveSync(const string &source, const string &destination,
432  const string &member, int64_t *out);
433 
435  void ZCard(const string &key, const IntegerCallback &callback,
436  const SerializationTag &tag = kDefaultSerializationTag);
437  void ZCount(const string &key, const string &min, const string &max,
438  const IntegerCallback &callback,
439  const SerializationTag &tag = kDefaultSerializationTag);
440  void ZScore(const string &key, const string &member,
441  const DoubleCallback &callback,
442  const SerializationTag &tag = kDefaultSerializationTag);
443  void ZRange(const string &key, int64_t start, int64_t stop,
444  bool with_scores, const StringDoublePairListCallback &callback,
445  const SerializationTag &tag = kDefaultSerializationTag);
446  void ZRangeByScore(const string &key, const string &min, const string &max,
447  bool with_scores,
448  const StringDoublePairListCallback &callback,
449  const SerializationTag &tag = kDefaultSerializationTag);
450  void ZRangeByScore(const string &key, const string &min, const string &max,
451  bool with_scores, uint64_t offset, uint64_t count,
452  const StringDoublePairListCallback &callback,
453  const SerializationTag &tag = kDefaultSerializationTag);
454  void ZRank(const string &key, const string &member,
455  const IntegerCallback &callback,
456  const SerializationTag &tag = kDefaultSerializationTag);
457  void ZRevRange(const string &key, int64_t start, int64_t stop,
458  bool with_scores,
459  const StringDoublePairListCallback &callback,
460  const SerializationTag &tag = kDefaultSerializationTag);
461  void ZRevRangeByScore(const string &key, const string &max, const string &min,
462  bool with_scores,
463  const StringDoublePairListCallback &callback,
464  const SerializationTag &tag = kDefaultSerializationTag);
465  void ZRevRangeByScore(const string &key, const string &max, const string &min,
466  bool with_scores, uint64_t offset, uint64_t count,
467  const StringDoublePairListCallback &callback,
468  const SerializationTag &tag = kDefaultSerializationTag);
469  void ZRevRank(const string &key, const string &member,
470  const IntegerCallback &callback,
471  const SerializationTag &tag = kDefaultSerializationTag);
472  void ZAdd(const string &key, double score, const string &member,
473  const IntegerCallback &callback,
474  const SerializationTag &tag = kDefaultSerializationTag);
475  void ZAdd(const string &key, const StringDoublePairList &score_members,
476  const IntegerCallback &callback,
477  const SerializationTag &tag = kDefaultSerializationTag);
478  void ZIncrBy(const string &key, double increment, const string &member,
479  const DoubleCallback &callback,
480  const SerializationTag &tag = kDefaultSerializationTag);
481  void ZRem(const string &key, const string &member,
482  const IntegerCallback &callback,
483  const SerializationTag &tag = kDefaultSerializationTag);
484  void ZRem(const string &key, const StringList &members,
485  const IntegerCallback &callback,
486  const SerializationTag &tag = kDefaultSerializationTag);
487  void ZRemRangeByRank(const string &key, int64_t start, int64_t stop,
488  const IntegerCallback &callback,
489  const SerializationTag &tag = kDefaultSerializationTag);
490  void ZRemRangeByScore(const string &key, const string &min, const string &max,
491  const IntegerCallback &callback,
492  const SerializationTag &tag = kDefaultSerializationTag);
493 
494  Result ZCardSync(const string &key, int64_t *out);
495  Result ZCountSync(const string &key, const string &min, const string &max,
496  int64_t *out);
497  Result ZScoreSync(const string &key, const string &member, double *out);
498  Result ZRangeSync(const string &key, int64_t start, int64_t stop,
499  bool with_scores, StringDoublePairList *out);
500  Result ZRangeByScoreSync(const string &key, const string &min,
501  const string &max, bool with_scores,
502  StringDoublePairList *out);
503  Result ZRangeByScoreSync(const string &key, const string &min,
504  const string &max, bool with_scores,
505  uint64_t offset, uint64_t count,
506  StringDoublePairList *out);
507  Result ZRankSync(const string &key, const string &member, int64_t *out);
508  Result ZRevRangeSync(const string &key, int64_t start, int64_t stop,
509  bool with_scores, StringDoublePairList *out);
510  Result ZRevRangeByScoreSync(const string &key, const string &max,
511  const string &min, bool with_scores,
512  StringDoublePairList *out);
513  Result ZRevRangeByScoreSync(const string &key, const string &max,
514  const string &min, bool with_scores,
515  uint64_t offset, uint64_t count,
516  StringDoublePairList *out);
517  Result ZRevRankSync(const string &key, const string &member, int64_t *out);
518  Result ZAddSync(const string &key, double score, const string &member,
519  int64_t *out);
520  Result ZAddSync(const string &key, const StringDoublePairList &score_members,
521  int64_t *out);
522  Result ZIncrBySync(const string &key, double increment, const string &member,
523  double *out);
524  Result ZRemSync(const string &key, const string &member, int64_t *out);
525  Result ZRemSync(const string &key, const StringList &members, int64_t *out);
526  Result ZRemRangeByRankSync(const string &key, int64_t start, int64_t stop,
527  int64_t *out);
528  Result ZRemRangeByScoreSync(const string &key, const string &min,
529  const string &max, int64_t *out);
530 
532  void Publish(const string &channel, const string &message,
533  const IntegerCallback &callback,
534  const SerializationTag &tag = kDefaultSerializationTag);
535  void Subscribe(const string &channel, const SubCallback &callback);
536  void Subscribe(const std::vector<string> &channels,
537  const SubCallback &callback);
538  void PSubscribe(const string &pattern, const PSubCallback &callback);
539  void PSubscribe(const std::vector<string> &patterns,
540  const PSubCallback &callback);
541  void Unsubscribe();
542  void Unsubscribe(const string &channel);
543  void Unsubscribe(const std::vector<string> &channels);
544  void PUnsubscribe();
545  void PUnsubscribe(const string &pattern);
546  void PUnsubscribe(const std::vector<string> &patterns);
547 
548  Result PublishSync(const string &channel, const string &message,
549  int64_t *out);
550 
551  void ExecuteCommand(const string &command_name,
552  const std::vector<string> *arguments,
553  const Callback &callback,
554  const SerializationTag &tag = kDefaultSerializationTag);
555  Ptr<Reply> ExecuteCommandSync(const string &command_name,
556  const std::vector<string> *arguments,
557  Result *result = NULL);
558 
559  private:
560  class Impl;
561 
562  RedisClient(const string &server_ip, int server_port,
563  const string &auth_pass, size_t connection_count,
564  bool invoke_as_event, size_t database);
565 
566  Ptr<Impl> impl_;
567 };
568 
569 } // namespace fun
570 
571 #endif // INCLUDE_FUNAPI_DATABASE_REDIS_CLIENT_H_
void SCard(const string &key, const IntegerCallback &callback, const SerializationTag &tag=kDefaultSerializationTag)
For redis commands 'Sets' section.
void Append(const string &key, const string &value, const IntegerCallback &callback, const SerializationTag &tag=kDefaultSerializationTag)
For redis commands 'Strings' section.
void LLen(const string &key, const IntegerCallback &callback, const SerializationTag &tag=kDefaultSerializationTag)
For redis commands 'Lists' section.
Definition: redis_client.h:22
void Publish(const string &channel, const string &message, const IntegerCallback &callback, const SerializationTag &tag=kDefaultSerializationTag)
For redis commands 'Pub/Sub' section.
void ZCard(const string &key, const IntegerCallback &callback, const SerializationTag &tag=kDefaultSerializationTag)
For redis commands 'Sorted Set' section.
Definition: redis_client.h:38
Definition: redis_client.h:24
Definition: json.h:27
void Del(const string &key, const IntegerCallback &callback, const SerializationTag &tag=kDefaultSerializationTag)
For redis commands 'Keys' section.
void HExists(const string &key, const string &field, const IntegerCallback &callback, const SerializationTag &tag=kDefaultSerializationTag)
For redis commands 'Hashes' section.