iFun Engine API  1.0.0-b2936
Great Technology for Great Games
 All Classes Files Functions Variables Typedefs Macros
redis.h
Go to the documentation of this file.
1 // Copyright (C) 2013-2015 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_H_
11 #define INCLUDE_FUNAPI_DATABASE_REDIS_H_
12 
13 #include <boost/bind.hpp>
14 #include <funapi/types.h>
15 
16 #include <vector>
17 
18 
19 namespace fun {
20 
21 class Redis {
22  public:
23  enum Result {
24  kResultError = 0,
25  kResultSuccess = 1,
26  kResultNil = 2,
27  kResultDisconnected = 3
28  };
29 
30  enum CommandOption {
31  kNone = -100,
32  kEX = 0,
33  kPX = 1,
34  kNX = 2,
35  kXX = 3
36  };
37 
38  struct Response {
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(Response);
49 
50  Type type;
51  int64_t integer;
52  string str;
53  std::vector<Ptr<Response> > elements;
54  };
55 
56  typedef std::pair<string, double> StrDoublePair;
57  typedef std::vector<StrDoublePair> StrDoublePairList;
58  typedef std::vector<string> StrList;
59  typedef std::pair<string, string> StrPair;
60  typedef std::vector<StrPair> StrPairList;
61 
64  typedef boost::function<void (
65  const Ptr<Response> &response)> OnResponseReturned;
66 
68  typedef boost::function<void (const Result &result)> OnNonReturned;
69  typedef boost::function<
70  void (const Result &result, const size_t &value)> OnSizeReturned;
71  typedef boost::function<
72  void (const Result &result, const bool &value)> OnBoolReturned;
73  typedef boost::function<
74  void (const Result &result, const int64_t &value)> OnIntReturned;
75  typedef boost::function<
76  void (const Result &result, const double &value)> OnDoubleReturned;
77  typedef boost::function<
78  void (const Result &result, const string &value)> OnStringReturned;
79  typedef boost::function<
80  void (const Result &result, const StrList &values)> OnStrListReturned;
81  typedef boost::function<
82  void (const Result &result,
83  const StrPairList &str_pairs)> OnStrPairListReturned;
84  typedef boost::function<
85  void (const Result &result,
86  const bool &value, const int64_t &value2)> OnBoolIntReturned;
87  typedef boost::function<
88  void (const Result &result,
89  const StrDoublePairList)> OnStrDoublePairListReturned;
90 
92  typedef boost::function<void (const string &channel,
93  const string &message)> OnSubCallback;
94  typedef boost::function<void (const string &pattern,
95  const string &channel,
96  const string &message)> OnPSubCallback;
97 
99  typedef boost::function<void (
100  const string &master_name,
101  // address: ip:port
102  const string &old_master_address,
103  // address: ip:port
104  const string &new_master_address)> OnSentinelMasterSwitched;
105 
107  static Result Del(const string &key,
108  size_t *del_count,
109  const string &tag = "");
110  static Result Del(const StrList &keys,
111  size_t *del_count,
112  const string &tag = "");
113  static Result Exists(const string &key, bool *exists, const string &tag = "");
114  static Result Expire(const string &key,
115  const size_t &seconds,
116  bool *is_set,
117  const string &tag = "");
118  static Result PExpire(const string &key,
119  const size_t &milliseconds,
120  bool *is_set,
121  const string &tag = "");
122  static Result Persist(const string &key,
123  bool *is_removed,
124  const string &tag = "");
125  static Result TTL(const string &key,
126  int64_t *remaining_ttl,
127  const string &tag = "");
128  static Result PTTL(const string &key,
129  int64_t *remaining_ttl,
130  const string &tag = "");
131  static Result Rename(const string &key,
132  const string &new_key,
133  const string &tag = "");
134 
135  static void DelAsync(const string &key,
136  const OnSizeReturned &callback,
137  const string &tag = "");
138  static void DelAsync(const StrList &keys,
139  const OnSizeReturned &callback,
140  const string &tag = "");
141  static void ExistsAsync(const string &key,
142  const OnBoolReturned &callback,
143  const string &tag = "");
144  static void ExpireAsync(const string &key,
145  const size_t &seconds,
146  const OnBoolReturned &callback,
147  const string &tag = "");
148  static void PExpireAsync(const string &key,
149  const size_t &milliseconds,
150  const OnBoolReturned &callback,
151  const string &tag = "");
152  static void PersistAsync(const string &key,
153  const OnBoolReturned &callback,
154  const string &tag = "");
155  static void TTLAsync(const string &key,
156  const OnIntReturned &callback,
157  const string &tag = "");
158  static void PTTLAsync(const string &key,
159  const OnIntReturned &callback,
160  const string &tag = "");
161  static void RenameAsync(const string &key,
162  const string &new_key,
163  const OnNonReturned &callback,
164  const string &tag = "");
165 
167  static Result Append(const string &key,
168  const string &value,
169  const string &tag = "");
170  static Result Incr(const string &key,
171  int64_t *increased,
172  const string &tag = "");
173  static Result IncrBy(const string &key,
174  const int64_t &increment,
175  int64_t *increased,
176  const string &tag = "");
177  static Result IncrByFloat(const string &key,
178  const double &increment,
179  double *increased,
180  const string &tag = "");
181  static Result Decr(const string &key,
182  int64_t *decreased,
183  const string &tag = "");
184  static Result DecrBy(const string &key,
185  const int64_t &decrement,
186  int64_t *decreased,
187  const string &tag = "");
188  static Result StrLen(const string &key,
189  size_t *length,
190  const string &tag = "");
191  static Result Get(const string &key,
192  string *value,
193  const string &tag = "");
194  static Result MGet(const StrList &keys,
195  StrList *values,
196  const string &tag = "");
197  static Result GetRange(const string &key,
198  const int64_t &start,
199  const int64_t &end,
200  string *value,
201  const string &tag = "");
202  static Result GetSet(const string &key,
203  const string &new_value,
204  string *old_value,
205  const string &tag = "");
206  static Result Set(const string &key,
207  const string &value,
208  const string &tag = "");
209  static Result Set(const string &key,
210  const string &value,
211  const CommandOption ex_or_px,
212  const size_t time,
213  const CommandOption nx_or_xx,
214  const string &tag = "");
215  static Result SetEx(const string &key,
216  const int64_t &seconds,
217  const string &value,
218  const string &tag = "");
219  static Result PSetEx(const string &key,
220  const int64_t &milliseconds,
221  const string &value,
222  const string &tag = "");
223  static Result SetNx(const string &key,
224  const string &value,
225  bool *already_exists,
226  const string &tag = "");
227  static Result MSet(const StrPairList &key_values, const string &tag = "");
228  static Result MSetNx(const StrPairList &key_values,
229  bool *already_exists,
230  const string &tag = "");
231  static Result BitCount(const string &key,
232  size_t *count,
233  const string &tag = "");
234  static Result BitCount(const string &key,
235  const int64_t &start,
236  const int64_t &end,
237  size_t *count,
238  const string &tag = "");
239  static Result BitOp(const string &operation,
240  const string &dest_key,
241  const StrList &keys,
242  size_t *dest_key_size,
243  const string &tag = "");
244  static Result GetBit(const string &key,
245  const size_t &offset,
246  bool *bit,
247  const string &tag = "");
248  static Result SetBit(const string &key,
249  const size_t &offset,
250  const bool &new_value,
251  bool *old_value,
252  const string &tag = "");
253 
254  static void AppendAsync(const string &key,
255  const string &value,
256  const OnNonReturned &callback,
257  const string &tag = "");
258  static void IncrAsync(const string &key,
259  const OnIntReturned &callback,
260  const string &tag = "");
261  static void IncrByAsync(const string &key,
262  const int64_t &increment,
263  const OnIntReturned &callback,
264  const string &tag = "");
265  static void IncrByFloatAsync(const string &key,
266  const double &increment,
267  const OnDoubleReturned &callback,
268  const string &tag = "");
269  static void DecrAsync(const string &key,
270  const OnIntReturned &callback,
271  const string &tag = "");
272  static void DecrByAsync(const string &key,
273  const int64_t &decrement,
274  const OnIntReturned &callback,
275  const string &tag = "");
276  static void StrLenAsync(const string &key,
277  const OnSizeReturned &callback,
278  const string &tag = "");
279  static void GetAsync(const string &key,
280  const OnStringReturned &callback,
281  const string &tag = "");
282  static void MGetAsync(const StrList &keys,
283  const OnStrListReturned &callback,
284  const string &tag = "");
285  static void GetRangeAsync(const string &key,
286  const int64_t &start,
287  const int64_t &end,
288  const OnStringReturned &callback,
289  const string &tag = "");
290  static void GetSetAsync(const string &key,
291  const string &new_value,
292  const OnStringReturned &callback,
293  const string &tag = "");
294  static void SetAsync(const string &key,
295  const string &value,
296  const OnNonReturned &callback,
297  const string &tag = "");
298  static void SetAsync(const string &key,
299  const string &value,
300  const CommandOption ex_or_px,
301  const size_t time,
302  const CommandOption nx_or_xx,
303  const OnNonReturned &callback,
304  const string &tag = "");
305  static void SetExAsync(const string &key,
306  const int64_t &seconds,
307  const string &value,
308  const OnNonReturned &callback,
309  const string &tag = "");
310  static void PSetExAsync(const string &key,
311  const int64_t &milliseconds,
312  const string &value,
313  const OnNonReturned &callback,
314  const string &tag = "");
315  static void SetNxAsync(const string &key,
316  const string &value,
317  const OnBoolReturned &callback,
318  const string &tag = "");
319  static void MSetAsync(const StrPairList &key_values,
320  const OnNonReturned &callback,
321  const string &tag = "");
322  static void MSetNxAsync(const StrPairList &key_values,
323  const OnBoolReturned &callback,
324  const string &tag = "");
325  static void BitCountAsync(const string &key,
326  const OnSizeReturned &callback,
327  const string &tag = "");
328  static void BitCountAsync(const string &key,
329  const int64_t &start,
330  const int64_t &end,
331  const OnSizeReturned &callback,
332  const string &tag = "");
333  static void BitOpAsync(const string &operation,
334  const string &dest_key,
335  const StrList &keys,
336  const OnSizeReturned &callback,
337  const string &tag = "");
338  static void GetBitAsync(const string &key,
339  const size_t &offset,
340  const OnBoolReturned &callback,
341  const string &tag = "");
342  static void SetBitAsync(const string &key,
343  const size_t &offset,
344  const bool &new_value,
345  const OnBoolReturned &callback,
346  const string &tag = "");
347 
349  static Result HExists(const string &key,
350  const string &field,
351  bool *exists,
352  const string &tag = "");
353  static Result HKeys(const string &key,
354  StrList *fields,
355  const string &tag = "");
356  static Result HVals(const string &key,
357  StrList *values,
358  const string &tag = "");
359  static Result HLen(const string &key,
360  size_t *field_count,
361  const string &tag = "");
362  static Result HIncrBy(const string &key,
363  const string &field,
364  const int64_t &increment,
365  int64_t *increased,
366  const string &tag = "");
367  static Result HIncrByFloat(const string &key,
368  const string &field,
369  const double &increment,
370  double *increased,
371  const string &tag = "");
372  static Result HDel(const string &key,
373  const string &field,
374  size_t *del_count,
375  const string &tag = "");
376  static Result HDel(const string &key,
377  const StrList &fields,
378  size_t *del_count,
379  const string &tag = "");
380  static Result HGet(const string &key,
381  const string &field,
382  string *value,
383  const string &tag = "");
384  static Result HGetAll(const string &key,
385  StrPairList *field_values,
386  const string &tag = "");
387  static Result HMGet(const string &key,
388  const StrList &fields,
389  StrList *values,
390  const string &tag = "");
391  static Result HSet(const string &key,
392  const string &field,
393  const string &value,
394  const string &tag = "");
395  static Result HSetNx(const string &key,
396  const string &field,
397  const string &value,
398  bool *already_exists,
399  const string &tag = "");
400  static Result HMSet(const string &key,
401  const StrPairList &field_values,
402  const string &tag = "");
403 
404  static void HExistsAsync(const string &key,
405  const string &field,
406  const OnBoolReturned &callback,
407  const string &tag = "");
408  static void HKeysAsync(const string &key,
409  const OnStrListReturned &callback,
410  const string &tag = "");
411  static void HValsAsync(const string &key,
412  const OnStrListReturned &callback,
413  const string &tag = "");
414  static void HLenAsync(const string &key,
415  const OnSizeReturned &callback,
416  const string &tag = "");
417  static void HIncrByAsync(const string &key,
418  const string &field,
419  const int64_t &increment,
420  const OnIntReturned &callback,
421  const string &tag = "");
422  static void HIncrByFloatAsync(const string &key,
423  const string &field,
424  const double &increment,
425  const OnDoubleReturned &callback,
426  const string &tag = "");
427  static void HDelAsync(const string &key,
428  const string &field,
429  const OnSizeReturned &callback,
430  const string &tag = "");
431  static void HDelAsync(const string &key,
432  const StrList &fields,
433  const OnSizeReturned &callback,
434  const string &tag = "");
435  static void HGetAsync(const string &key,
436  const string &field,
437  const OnStringReturned &callback,
438  const string &tag = "");
439  static void HGetAllAsync(const string &key,
440  const OnStrPairListReturned &callback,
441  const string &tag = "");
442  static void HMGetAsync(const string &key,
443  const StrList &fields,
444  const OnStrListReturned &callback,
445  const string &tag = "");
446  static void HSetAsync(const string &key,
447  const string &field,
448  const string &value,
449  const OnNonReturned &callback,
450  const string &tag = "");
451  static void HSetNxAsync(const string &key,
452  const string &field,
453  const string &value,
454  const OnBoolReturned &callback,
455  const string &tag = "");
456  static void HMSetAsync(const string &key,
457  const StrPairList &field_values,
458  const OnNonReturned &callback,
459  const string &tag = "");
460 
462  static Result LLen(const string &key,
463  size_t *length,
464  const string &tag = "");
465  static Result LIndex(const string &key,
466  const int64_t &index,
467  string *value,
468  const string &tag = "");
469  static Result LRange(const string &key,
470  const int64_t &start,
471  const int64_t &stop,
472  StrList *values,
473  const string &tag = "");
474  static Result LRem(const string &key,
475  const int64_t &count,
476  const string &value,
477  size_t *rem_count,
478  const string &tag = "");
479  static Result LTrim(const string &key,
480  const int64_t &start,
481  const int64_t &stop,
482  const string &tag = "");
483  static Result LPush(const string &key,
484  const string &value,
485  size_t *total_length,
486  const string &tag = "");
487  static Result LPush(const string &key,
488  const StrList &values,
489  size_t *total_length,
490  const string &tag = "");
491  static Result RPush(const string &key,
492  const string &value,
493  size_t *total_length,
494  const string &tag = "");
495  static Result RPush(const string &key,
496  const StrList &values,
497  size_t *total_length,
498  const string &tag = "");
499  static Result LPop(const string &key,
500  string *value,
501  const string &tag = "");
502  static Result RPop(const string &key,
503  string *value,
504  const string &tag = "");
505  static Result LInsert(const string &key,
506  const bool &before,
507  const string &pivot,
508  const string &value,
509  bool *key_or_pivot_not_found,
510  int64_t *total_length,
511  const string &tag = "");
512  static Result LSet(const string &key,
513  const int64_t &index,
514  const string &value,
515  const string &tag = "");
516 
517  static void LLenAsync(const string &key,
518  const OnSizeReturned &callback,
519  const string &tag = "");
520  static void LIndexAsync(const string &key,
521  const int64_t &index,
522  const OnStringReturned &callback,
523  const string &tag = "");
524  static void LRangeAsync(const string &key,
525  const int64_t &start,
526  const int64_t &stop,
527  const OnStrListReturned &callback,
528  const string &tag = "");
529  static void LRemAsync(const string &key,
530  const int64_t &count,
531  const string &value,
532  const OnSizeReturned &callback,
533  const string &tag = "");
534  static void LTrimAsync(const string &key,
535  const int64_t &start,
536  const int64_t &stop,
537  const OnNonReturned &callback,
538  const string &tag = "");
539  static void LPushAsync(const string &key,
540  const string &value,
541  const OnSizeReturned &callback,
542  const string &tag = "");
543  static void LPushAsync(const string &key,
544  const StrList &values,
545  const OnSizeReturned &callback,
546  const string &tag = "");
547  static void RPushAsync(const string &key,
548  const string &value,
549  const OnSizeReturned &callback,
550  const string &tag = "");
551  static void RPushAsync(const string &key,
552  const StrList &values,
553  const OnSizeReturned &callback,
554  const string &tag = "");
555  static void LPopAsync(const string &key,
556  const OnStringReturned &callback,
557  const string &tag = "");
558  static void RPopAsync(const string &key,
559  const OnStringReturned &callback,
560  const string &tag = "");
561  static void LInsertAsync(const string &key,
562  const bool &before,
563  const string &pivot,
564  const string &value,
565  const OnBoolIntReturned &callback,
566  const string &tag = "");
567  static void LSetAsync(const string &key,
568  const int64_t &index,
569  const string &value,
570  const OnNonReturned &callback,
571  const string &tag = "");
572 
574  static Result SCard(const string &key,
575  size_t *cardinality,
576  const string &tag = "");
577  static Result SIsMember(const string &key,
578  const string &member,
579  bool *is_member,
580  const string &tag = "");
581  static Result SMembers(const string &key,
582  StrList *members,
583  const string &tag = "");
584  static Result SRandMember(const string &key,
585  string *member,
586  const string &tag = "");
587  static Result SRandMember(const string &key,
588  const int64_t &count,
589  StrList *members,
590  const string &tag = "");
591  static Result SDiff(const StrList &keys,
592  StrList *members,
593  const string &tag = "");
594  static Result SDiffStore(const string &destination,
595  const StrList &keys,
596  size_t *destination_size,
597  const string &tag = "");
598  static Result SInter(const StrList &keys,
599  StrList *members,
600  const string &tag = "");
601  static Result SInterStore(const string &destination,
602  const StrList &keys,
603  size_t *destination_size,
604  const string &tag = "");
605  static Result SUnion(const StrList &keys,
606  StrList *members,
607  const string &tag = "");
608  static Result SUnionStore(const string &destination,
609  const StrList &keys,
610  size_t *destination_size,
611  const string &tag = "");
612  static Result SAdd(const string &key,
613  const string &member,
614  size_t *add_count,
615  const string &tag = "");
616  static Result SAdd(const string &key,
617  const StrList &members,
618  size_t *add_count,
619  const string &tag = "");
620  static Result SPop(const string &key,
621  string *member,
622  const string &tag = "");
623  static Result SRem(const string &key,
624  const string &member,
625  size_t *rem_count,
626  const string &tag = "");
627  static Result SRem(const string &key,
628  const StrList &members,
629  size_t *rem_count,
630  const string &tag = "");
631  static Result SMove(const string &source,
632  const string &destination,
633  const string &member,
634  bool *is_moved,
635  const string &tag = "");
636 
637  static void SCardAsync(const string &key,
638  const OnSizeReturned &callback,
639  const string &tag = "");
640  static void SIsMemberAsync(const string &key,
641  const string &member,
642  const OnBoolReturned &callback,
643  const string &tag = "");
644  static void SMembersAsync(const string &key,
645  const OnStrListReturned &callback,
646  const string &tag = "");
647  static void SRandMemberAsync(const string &key,
648  const OnStringReturned &callback,
649  const string &tag = "");
650  static void SRandMemberAsync(const string &key,
651  const int64_t &count,
652  const OnStrListReturned &callback,
653  const string &tag = "");
654  static void SDiffAsync(const StrList &keys,
655  const OnStrListReturned &callback,
656  const string &tag = "");
657  static void SDiffStoreAsync(const string &destination,
658  const StrList &keys,
659  const OnSizeReturned &callback,
660  const string &tag = "");
661  static void SInterAsync(const StrList &keys,
662  const OnStrListReturned &callback,
663  const string &tag = "");
664  static void SInterStoreAsync(const string &destination,
665  const StrList &keys,
666  const OnSizeReturned &callback,
667  const string &tag = "");
668  static void SUnionAsync(const StrList &keys,
669  const OnStrListReturned &callback,
670  const string &tag = "");
671  static void SUnionStoreAsync(const string &destination,
672  const StrList &keys,
673  const OnSizeReturned &callback,
674  const string &tag = "");
675  static void SAddAsync(const string &key,
676  const string &member,
677  const OnSizeReturned &callback,
678  const string &tag = "");
679  static void SAddAsync(const string &key,
680  const StrList &members,
681  const OnSizeReturned &callback,
682  const string &tag = "");
683  static void SPopAsync(const string &key,
684  const OnStringReturned &callback,
685  const string &tag = "");
686  static void SRemAsync(const string &key,
687  const string &member,
688  const OnSizeReturned &callback,
689  const string &tag = "");
690  static void SRemAsync(const string &key,
691  const StrList &members,
692  const OnSizeReturned &callback,
693  const string &tag = "");
694  static void SMoveAsync(const string &source,
695  const string &destination,
696  const string &member,
697  const OnBoolReturned &callback,
698  const string &tag = "");
699 
701  static Result ZCard(const string &key,
702  size_t *cardinality,
703  const string &tag = "");
704  static Result ZCount(const string &key,
705  const string &min,
706  const string &max,
707  size_t *count,
708  const string &tag = "");
709  static Result ZScore(const string &key,
710  const string &member,
711  double *score,
712  const string &tag = "");
713  static Result ZRevRank(const string &key,
714  const string &member,
715  size_t *rank,
716  const string &tag = "");
717  static Result ZRevRange(const string &key,
718  const int64_t &start,
719  const int64_t &stop,
720  const bool &withscores,
721  StrDoublePairList *member_scores,
722  const string &tag = "");
723  static Result ZAdd(const string &key,
724  const double &score,
725  const string &member,
726  const string &tag = "");
727  static Result ZIncrBy(const string &key,
728  const double &increment,
729  const string &member,
730  double *new_score,
731  const string &tag = "");
732  static Result ZRem(const string &key,
733  const string &member,
734  size_t *del_count,
735  const string &tag = "");
736  static Result ZRem(const string &key,
737  const StrList &members,
738  size_t *del_count,
739  const string &tag = "");
740 
741  static void ZCardAsync(const string &key,
742  const OnSizeReturned &callback,
743  const string &tag = "");
744  static void ZCountAsync(const string &key,
745  const string &min,
746  const string &max,
747  const OnSizeReturned &callback,
748  const string &tag = "");
749  static void ZScoreAsync(const string &key,
750  const string &member,
751  const OnDoubleReturned &callback,
752  const string &tag = "");
753  static void ZRevRankAsync(const string &key,
754  const string &member,
755  const OnSizeReturned &callback,
756  const string &tag = "");
757  static void ZRevRangeAsync(const string &key,
758  const int64_t &start,
759  const int64_t &stop,
760  const bool &withscores,
761  const OnStrDoublePairListReturned &callback,
762  const string &tag = "");
763  static void ZAddAsync(const string &key,
764  const double &score,
765  const string &member,
766  const OnNonReturned &callback,
767  const string &tag = "");
768  static void ZIncrByAsync(const string &key,
769  const double &increment,
770  const string &member,
771  const OnDoubleReturned &callback,
772  const string &tag = "");
773  static void ZRemAsync(const string &key,
774  const string &member,
775  const OnSizeReturned &callback,
776  const string &tag = "");
777  static void ZRemAsync(const string &key,
778  const StrList &members,
779  const OnSizeReturned &callback,
780  const string &tag = "");
781 
783  // 'Subscribe' and 'PSubscribe' interface does not support.
784  // Use 'SubscribeAsync' and 'PSubscribeAsync' interface instead.
785 
786  static Result Publish(const string &channel,
787  const string &message,
788  size_t *received_client_count,
789  const string &tag = "");
790  static Result Unsubscribe(const string &tag = "");
791  static Result Unsubscribe(const string &channel, const string &tag = "");
792  static Result Unsubscribe(const StrList &channels, const string &tag = "");
793  static Result PUnsubscribe(const string &tag = "");
794  static Result PUnsubscribe(const string &pattern, const string &tag = "");
795  static Result PUnsubscribe(const StrList &patterns, const string &tag = "");
796 
797  static void PublishAsync(const string &channel,
798  const string &message,
799  const OnSizeReturned &callback,
800  const string &tag = "");
801  static void SubscribeAsync(const string &channel,
802  const OnSubCallback &callback,
803  const string &tag = "");
804  static void SubscribeAsync(const StrList &channels,
805  const OnSubCallback &callback,
806  const string &tag = "");
807  static void PSubscribeAsync(const string &pattern,
808  const OnPSubCallback &callback,
809  const string &tag = "");
810  static void PSubscribeAsync(const StrList &patterns,
811  const OnPSubCallback &callback,
812  const string &tag = "");
813  static void UnsubscribeAsync(const OnNonReturned &callback,
814  const string &tag = "");
815  static void UnsubscribeAsync(const string &channel,
816  const OnNonReturned &callback,
817  const string &tag = "");
818  static void UnsubscribeAsync(const StrList &channels,
819  const OnNonReturned &callback,
820  const string &tag = "");
821  static void PUnsubscribeAsync(const OnNonReturned &callback,
822  const string &tag = "");
823  static void PUnsubscribeAsync(const string &pattern,
824  const OnNonReturned &callback,
825  const string &tag = "");
826  static void PUnsubscribeAsync(const StrList &patterns,
827  const OnNonReturned &callback,
828  const string &tag = "");
829 
831 
832  static Result Multi(const string &tag = "");
833  static Ptr<Response> Exec(const string &tag = "");
834  static Result Discard(const string &tag = "");
835 
838  const OnSentinelMasterSwitched &cb,
839  const string &tag = "");
840 
841 
842  static Ptr<Response> ExecuteCommand(const string &command_name,
843  const std::vector<string> *arguments,
844  const string &tag = "");
845  static void ExecuteCommandAsync(const string &command_name,
846  const std::vector<string> *arguments,
847  const OnResponseReturned &callback,
848  const string &tag = "");
849 };
850 
851 } // namespace fun
852 
853 #endif // INCLUDE_FUNAPI_DATABASE_REDIS_H_
static Result Multi(const string &tag="")
For redis commands 'Transaction' section.
static Result Del(const string &key, size_t *del_count, const string &tag="")
For redis commands 'Keys' section.
static Result Append(const string &key, const string &value, const string &tag="")
For redis commands 'Strings' section.
boost::function< void(const Result &result)> OnNonReturned
for redis command functions
Definition: redis.h:68
static Result LLen(const string &key, size_t *length, const string &tag="")
For redis commands 'Lists' section.
static Result Publish(const string &channel, const string &message, size_t *received_client_count, const string &tag="")
For redis commands 'Pub/Sub' section.
static void SubscribeSentinelSwitchMasterChannelAsync(const OnSentinelMasterSwitched &cb, const string &tag="")
For redis sentinel section.
boost::function< void(const string &master_name, const string &old_master_address, const string &new_master_address)> OnSentinelMasterSwitched
for Redis Sentinel
Definition: redis.h:104
boost::function< void(const Ptr< Response > &response)> OnResponseReturned
Callbacks for redis async commands for CommandAsync function.
Definition: redis.h:65
boost::function< void(const string &channel, const string &message)> OnSubCallback
for (p)subscribe redis commands
Definition: redis.h:93
static Result SCard(const string &key, size_t *cardinality, const string &tag="")
For redis commands 'Sets' section.
static Result HExists(const string &key, const string &field, bool *exists, const string &tag="")
For redis commands 'Hashes' section.
Definition: redis.h:38
Definition: redis.h:21
static Result ZCard(const string &key, size_t *cardinality, const string &tag="")
For redis commands 'Sorted Set' section.