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