cpp_redis  4.0.0
cpp_redis is a C++11 Asynchronous Multi-Platform Lightweight Redis Client, with support for synchronous operations and pipelining.
client.hpp
1 // The MIT License (MIT)
2 //
3 // Copyright (c) 2015-2017 Simon Ninon <simon.ninon@gmail.com>
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in all
13 // copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 // SOFTWARE.
22 
23 #pragma once
24 
25 #include <atomic>
26 #include <condition_variable>
27 #include <functional>
28 #include <future>
29 #include <map>
30 #include <mutex>
31 #include <queue>
32 #include <string>
33 #include <vector>
34 
35 #include <cpp_redis/core/sentinel.hpp>
36 #include <cpp_redis/helpers/variadic_template.hpp>
37 #include <cpp_redis/misc/logger.hpp>
38 #include <cpp_redis/network/redis_connection.hpp>
39 #include <cpp_redis/network/tcp_client_iface.hpp>
40 
41 namespace cpp_redis {
42 
48 class client {
49 public:
54  enum class client_type {
55  normal,
56  master,
57  pubsub,
58  slave
59  };
60 
71  enum class connect_state {
72  dropped,
73  start,
74  sleeping,
75  ok,
76  failed,
77  lookup_failed,
78  stopped
79  };
80 
81 public:
82 #ifndef __CPP_REDIS_USE_CUSTOM_TCP_CLIENT
83  client(void);
85 #endif /* __CPP_REDIS_USE_CUSTOM_TCP_CLIENT */
86 
92  explicit client(const std::shared_ptr<network::tcp_client_iface>& tcp_client);
93 
95  ~client(void);
96 
98  client(const client&) = delete;
100  client& operator=(const client&) = delete;
101 
102 public:
106  typedef std::function<void(const std::string& host, std::size_t port, connect_state status)> connect_callback_t;
107 
118  void connect(
119  const std::string& host = "127.0.0.1",
120  std::size_t port = 6379,
121  const connect_callback_t& connect_callback = nullptr,
122  std::uint32_t timeout_msecs = 0,
123  std::int32_t max_reconnects = 0,
124  std::uint32_t reconnect_interval_msecs = 0);
125 
135  void connect(
136  const std::string& name,
137  const connect_callback_t& connect_callback = nullptr,
138  std::uint32_t timeout_msecs = 0,
139  std::int32_t max_reconnects = 0,
140  std::uint32_t reconnect_interval_msecs = 0);
141 
145  bool is_connected(void) const;
146 
152  void disconnect(bool wait_for_removal = false);
153 
157  bool is_reconnecting(void) const;
158 
162  void cancel_reconnect(void);
163 
164 public:
169  typedef std::function<void(reply&)> reply_callback_t;
170 
180  client& send(const std::vector<std::string>& redis_cmd, const reply_callback_t& callback);
181 
189  std::future<reply> send(const std::vector<std::string>& redis_cmd);
190 
199  client& commit(void);
200 
207  client& sync_commit(void);
208 
215  template <class Rep, class Period>
216  client&
217  sync_commit(const std::chrono::duration<Rep, Period>& timeout) {
220  if (!is_reconnecting()) {
221  try_commit();
222  }
223 
224  std::unique_lock<std::mutex> lock_callback(m_callbacks_mutex);
225  __CPP_REDIS_LOG(debug, "cpp_redis::client waiting for callbacks to complete");
226  if (!m_sync_condvar.wait_for(lock_callback, timeout, [=] { return m_callbacks_running == 0 && m_commands.empty(); })) {
227  __CPP_REDIS_LOG(debug, "cpp_redis::client finished waiting for callback");
228  }
229  else {
230  __CPP_REDIS_LOG(debug, "cpp_redis::client timed out waiting for callback");
231  }
232 
233  return *this;
234  }
235 
236 private:
240  bool should_reconnect(void) const;
241 
245  void resend_failed_commands(void);
246 
250  void sleep_before_next_reconnect_attempt(void);
251 
256  void reconnect(void);
257 
261  void re_auth(void);
262 
266  void re_select(void);
267 
268 private:
276  void unprotected_send(const std::vector<std::string>& redis_cmd, const reply_callback_t& callback);
277 
285  void unprotected_auth(const std::string& password, const reply_callback_t& reply_callback);
286 
294  void unprotected_select(int index, const reply_callback_t& reply_callback);
295 
296 public:
304  void add_sentinel(const std::string& host, std::size_t port, std::uint32_t timeout_msecs = 0);
305 
311  const sentinel& get_sentinel(void) const;
312 
319  sentinel& get_sentinel(void);
320 
324  void clear_sentinels(void);
325 
326 public:
332  enum class aggregate_method {
333  sum,
334  min,
335  max,
336  server_default
337  };
338 
345  std::string aggregate_method_to_string(aggregate_method method) const;
346 
347 public:
352  enum class geo_unit {
353  m,
354  km,
355  ft,
356  mi
357  };
358 
365  std::string geo_unit_to_string(geo_unit unit) const;
366 
367 public:
373  enum class overflow_type {
374  wrap,
375  sat,
376  fail,
377  server_default
378  };
379 
386  std::string overflow_type_to_string(overflow_type type) const;
387 
388 public:
394  get,
395  set,
396  incrby
397  };
398 
405  std::string
407 
408 public:
417 
421  std::string type;
422 
426  int offset;
427 
431  int value;
432 
437 
446  static bitfield_operation get(const std::string& type, int offset, overflow_type overflow = overflow_type::server_default);
447 
457  static bitfield_operation set(const std::string& type, int offset, int value, overflow_type overflow = overflow_type::server_default);
458 
468  static bitfield_operation incrby(const std::string& type, int offset, int increment, overflow_type overflow = overflow_type::server_default);
469  };
470 
471 public:
472  client&
473  append(const std::string& key, const std::string& value, const reply_callback_t& reply_callback);
474  std::future<reply> append(const std::string& key, const std::string& value);
475 
476  client& auth(const std::string& password, const reply_callback_t& reply_callback);
477  std::future<reply> auth(const std::string& password);
478 
479  client& bgrewriteaof(const reply_callback_t& reply_callback);
480  std::future<reply> bgrewriteaof();
481 
482  client& bgsave(const reply_callback_t& reply_callback);
483  std::future<reply> bgsave();
484 
485  client& bitcount(const std::string& key, const reply_callback_t& reply_callback);
486  std::future<reply> bitcount(const std::string& key);
487 
488  client& bitcount(const std::string& key, int start, int end, const reply_callback_t& reply_callback);
489  std::future<reply> bitcount(const std::string& key, int start, int end);
490 
491  client& bitfield(const std::string& key, const std::vector<bitfield_operation>& operations, const reply_callback_t& reply_callback);
492  std::future<reply> bitfield(const std::string& key, const std::vector<bitfield_operation>& operations);
493 
494  client& bitop(const std::string& operation, const std::string& destkey, const std::vector<std::string>& keys, const reply_callback_t& reply_callback);
495  std::future<reply> bitop(const std::string& operation, const std::string& destkey, const std::vector<std::string>& keys);
496 
497  client& bitpos(const std::string& key, int bit, const reply_callback_t& reply_callback);
498  std::future<reply> bitpos(const std::string& key, int bit);
499 
500  client& bitpos(const std::string& key, int bit, int start, const reply_callback_t& reply_callback);
501  std::future<reply> bitpos(const std::string& key, int bit, int start);
502 
503  client& bitpos(const std::string& key, int bit, int start, int end, const reply_callback_t& reply_callback);
504  std::future<reply> bitpos(const std::string& key, int bit, int start, int end);
505 
506  client& blpop(const std::vector<std::string>& keys, int timeout, const reply_callback_t& reply_callback);
507  std::future<reply> blpop(const std::vector<std::string>& keys, int timeout);
508 
509  client& brpop(const std::vector<std::string>& keys, int timeout, const reply_callback_t& reply_callback);
510  std::future<reply> brpop(const std::vector<std::string>& keys, int timeout);
511 
512  client& brpoplpush(const std::string& src, const std::string& dst, int timeout, const reply_callback_t& reply_callback);
513  std::future<reply> brpoplpush(const std::string& src, const std::string& dst, int timeout);
514 
515  template <typename T, typename... Ts>
516  client& client_kill(const std::string& host, int port, const T& arg, const Ts&... args);
517  client& client_kill(const std::string& host, int port);
518  template <typename... Ts>
519  client& client_kill(const char* host, int port, const Ts&... args);
520  template <typename T, typename... Ts>
521  client& client_kill(const T&, const Ts&...);
522  template <typename T, typename... Ts>
523  std::future<reply> client_kill_future(const T, const Ts...);
524 
525  client& client_list(const reply_callback_t& reply_callback);
526  std::future<reply> client_list();
527 
528  client& client_getname(const reply_callback_t& reply_callback);
529  std::future<reply> client_getname();
530 
531  client& client_pause(int timeout, const reply_callback_t& reply_callback);
532  std::future<reply> client_pause(int timeout);
533 
534  client& client_reply(const std::string& mode, const reply_callback_t& reply_callback);
535  std::future<reply> client_reply(const std::string& mode);
536 
537  client& client_setname(const std::string& name, const reply_callback_t& reply_callback);
538  std::future<reply> client_setname(const std::string& name);
539 
540  client& cluster_addslots(const std::vector<std::string>& p_slots, const reply_callback_t& reply_callback);
541  std::future<reply> cluster_addslots(const std::vector<std::string>& p_slots);
542 
543  client& cluster_count_failure_reports(const std::string& node_id, const reply_callback_t& reply_callback);
544  std::future<reply> cluster_count_failure_reports(const std::string& node_id);
545 
546  client& cluster_countkeysinslot(const std::string& slot, const reply_callback_t& reply_callback);
547  std::future<reply> cluster_countkeysinslot(const std::string& slot);
548 
549  client& cluster_delslots(const std::vector<std::string>& p_slots, const reply_callback_t& reply_callback);
550  std::future<reply> cluster_delslots(const std::vector<std::string>& p_slots);
551 
552  client& cluster_failover(const reply_callback_t& reply_callback);
553  std::future<reply> cluster_failover();
554 
555  client& cluster_failover(const std::string& mode, const reply_callback_t& reply_callback);
556  std::future<reply> cluster_failover(const std::string& mode);
557 
558  client& cluster_forget(const std::string& node_id, const reply_callback_t& reply_callback);
559  std::future<reply> cluster_forget(const std::string& node_id);
560 
561  client& cluster_getkeysinslot(const std::string& slot, int count, const reply_callback_t& reply_callback);
562  std::future<reply> cluster_getkeysinslot(const std::string& slot, int count);
563 
564  client& cluster_info(const reply_callback_t& reply_callback);
565  std::future<reply> cluster_info();
566 
567  client& cluster_keyslot(const std::string& key, const reply_callback_t& reply_callback);
568  std::future<reply> cluster_keyslot(const std::string& key);
569 
570  client& cluster_meet(const std::string& ip, int port, const reply_callback_t& reply_callback);
571  std::future<reply> cluster_meet(const std::string& ip, int port);
572 
573  client& cluster_nodes(const reply_callback_t& reply_callback);
574  std::future<reply> cluster_nodes();
575 
576  client& cluster_replicate(const std::string& node_id, const reply_callback_t& reply_callback);
577  std::future<reply> cluster_replicate(const std::string& node_id);
578 
579  client& cluster_reset(const reply_callback_t& reply_callback);
580  client& cluster_reset(const std::string& mode, const reply_callback_t& reply_callback);
581  std::future<reply> cluster_reset(const std::string& mode = "soft");
582 
583  client& cluster_saveconfig(const reply_callback_t& reply_callback);
584  std::future<reply> cluster_saveconfig();
585 
586  client& cluster_set_config_epoch(const std::string& epoch, const reply_callback_t& reply_callback);
587  std::future<reply> cluster_set_config_epoch(const std::string& epoch);
588 
589  client& cluster_setslot(const std::string& slot, const std::string& mode, const reply_callback_t& reply_callback);
590  std::future<reply> cluster_setslot(const std::string& slot, const std::string& mode);
591 
592  client& cluster_setslot(const std::string& slot, const std::string& mode, const std::string& node_id, const reply_callback_t& reply_callback);
593  std::future<reply> cluster_setslot(const std::string& slot, const std::string& mode, const std::string& node_id);
594 
595  client& cluster_slaves(const std::string& node_id, const reply_callback_t& reply_callback);
596  std::future<reply> cluster_slaves(const std::string& node_id);
597 
598  client& cluster_slots(const reply_callback_t& reply_callback);
599  std::future<reply> cluster_slots();
600 
601  client& command(const reply_callback_t& reply_callback);
602  std::future<reply> command();
603 
604  client& command_count(const reply_callback_t& reply_callback);
605  std::future<reply> command_count();
606 
607  client& command_getkeys(const reply_callback_t& reply_callback);
608  std::future<reply> command_getkeys();
609 
610  client& command_info(const std::vector<std::string>& command_name, const reply_callback_t& reply_callback);
611  std::future<reply> command_info(const std::vector<std::string>& command_name);
612 
613  client& config_get(const std::string& param, const reply_callback_t& reply_callback);
614  std::future<reply> config_get(const std::string& param);
615 
616  client& config_rewrite(const reply_callback_t& reply_callback);
617  std::future<reply> config_rewrite();
618 
619  client& config_set(const std::string& param, const std::string& val, const reply_callback_t& reply_callback);
620  std::future<reply> config_set(const std::string& param, const std::string& val);
621 
622  client& config_resetstat(const reply_callback_t& reply_callback);
623  std::future<reply> config_resetstat();
624 
625  client& dbsize(const reply_callback_t& reply_callback);
626  std::future<reply> dbsize();
627 
628  client& debug_object(const std::string& key, const reply_callback_t& reply_callback);
629  std::future<reply> debug_object(const std::string& key);
630 
631  client& debug_segfault(const reply_callback_t& reply_callback);
632  std::future<reply> debug_segfault();
633 
634  client& decr(const std::string& key, const reply_callback_t& reply_callback);
635  std::future<reply> decr(const std::string& key);
636 
637  client& decrby(const std::string& key, int val, const reply_callback_t& reply_callback);
638  std::future<reply> decrby(const std::string& key, int val);
639 
640  client& del(const std::vector<std::string>& key, const reply_callback_t& reply_callback);
641  std::future<reply> del(const std::vector<std::string>& key);
642 
643  client& discard(const reply_callback_t& reply_callback);
644  std::future<reply> discard();
645 
646  client& dump(const std::string& key, const reply_callback_t& reply_callback);
647  std::future<reply> dump(const std::string& key);
648 
649  client& echo(const std::string& msg, const reply_callback_t& reply_callback);
650  std::future<reply> echo(const std::string& msg);
651 
652  client& eval(const std::string& script, int numkeys, const std::vector<std::string>& keys, const std::vector<std::string>& args, const reply_callback_t& reply_callback);
653  std::future<reply> eval(const std::string& script, int numkeys, const std::vector<std::string>& keys, const std::vector<std::string>& args);
654 
655  client& evalsha(const std::string& sha1, int numkeys, const std::vector<std::string>& keys, const std::vector<std::string>& args, const reply_callback_t& reply_callback);
656  std::future<reply> evalsha(const std::string& sha1, int numkeys, const std::vector<std::string>& keys, const std::vector<std::string>& args);
657 
658  client& exec(const reply_callback_t& reply_callback);
659  std::future<reply> exec();
660 
661  client& exists(const std::vector<std::string>& keys, const reply_callback_t& reply_callback);
662  std::future<reply> exists(const std::vector<std::string>& keys);
663 
664  client& expire(const std::string& key, int seconds, const reply_callback_t& reply_callback);
665  std::future<reply> expire(const std::string& key, int seconds);
666 
667  client& expireat(const std::string& key, int timestamp, const reply_callback_t& reply_callback);
668  std::future<reply> expireat(const std::string& key, int timestamp);
669 
670  client& flushall(const reply_callback_t& reply_callback);
671  std::future<reply> flushall();
672 
673  client& flushdb(const reply_callback_t& reply_callback);
674  std::future<reply> flushdb();
675 
676  client& geoadd(const std::string& key, const std::vector<std::tuple<std::string, std::string, std::string>>& long_lat_memb, const reply_callback_t& reply_callback);
677  std::future<reply> geoadd(const std::string& key, const std::vector<std::tuple<std::string, std::string, std::string>>& long_lat_memb);
678 
679  client& geohash(const std::string& key, const std::vector<std::string>& members, const reply_callback_t& reply_callback);
680  std::future<reply> geohash(const std::string& key, const std::vector<std::string>& members);
681 
682  client& geopos(const std::string& key, const std::vector<std::string>& members, const reply_callback_t& reply_callback);
683  std::future<reply> geopos(const std::string& key, const std::vector<std::string>& members);
684 
685  client& geodist(const std::string& key, const std::string& member_1, const std::string& member_2, const reply_callback_t& reply_callback);
686  client& geodist(const std::string& key, const std::string& member_1, const std::string& member_2, const std::string& unit, const reply_callback_t& reply_callback);
687  std::future<reply> geodist(const std::string& key, const std::string& member_1, const std::string& member_2, const std::string& unit = "m");
688 
689  client& georadius(const std::string& key, double longitude, double latitude, double radius, geo_unit unit, bool with_coord, bool with_dist, bool with_hash, bool asc_order, const reply_callback_t& reply_callback);
690  client& georadius(const std::string& key, double longitude, double latitude, double radius, geo_unit unit, bool with_coord, bool with_dist, bool with_hash, bool asc_order, std::size_t count, const reply_callback_t& reply_callback);
691  client& georadius(const std::string& key, double longitude, double latitude, double radius, geo_unit unit, bool with_coord, bool with_dist, bool with_hash, bool asc_order, const std::string& store_key, const reply_callback_t& reply_callback);
692  client& georadius(const std::string& key, double longitude, double latitude, double radius, geo_unit unit, bool with_coord, bool with_dist, bool with_hash, bool asc_order, const std::string& store_key, const std::string& storedist_key, const reply_callback_t& reply_callback);
693  client& georadius(const std::string& key, double longitude, double latitude, double radius, geo_unit unit, bool with_coord, bool with_dist, bool with_hash, bool asc_order, std::size_t count, const std::string& store_key, const reply_callback_t& reply_callback);
694  client& georadius(const std::string& key, double longitude, double latitude, double radius, geo_unit unit, bool with_coord, bool with_dist, bool with_hash, bool asc_order, std::size_t count, const std::string& store_key, const std::string& storedist_key, const reply_callback_t& reply_callback);
695  std::future<reply> georadius(const std::string& key, double longitude, double latitude, double radius, geo_unit unit, bool with_coord = false, bool with_dist = false, bool with_hash = false, bool asc_order = false, std::size_t count = 0, const std::string& store_key = "", const std::string& storedist_key = "");
696 
697  client& georadiusbymember(const std::string& key, const std::string& member, double radius, geo_unit unit, bool with_coord, bool with_dist, bool with_hash, bool asc_order, const reply_callback_t& reply_callback);
698  client& georadiusbymember(const std::string& key, const std::string& member, double radius, geo_unit unit, bool with_coord, bool with_dist, bool with_hash, bool asc_order, std::size_t count, const reply_callback_t& reply_callback);
699  client& georadiusbymember(const std::string& key, const std::string& member, double radius, geo_unit unit, bool with_coord, bool with_dist, bool with_hash, bool asc_order, const std::string& store_key, const reply_callback_t& reply_callback);
700  client& georadiusbymember(const std::string& key, const std::string& member, double radius, geo_unit unit, bool with_coord, bool with_dist, bool with_hash, bool asc_order, const std::string& store_key, const std::string& storedist_key, const reply_callback_t& reply_callback);
701  client& georadiusbymember(const std::string& key, const std::string& member, double radius, geo_unit unit, bool with_coord, bool with_dist, bool with_hash, bool asc_order, std::size_t count, const std::string& store_key, const reply_callback_t& reply_callback);
702  client& georadiusbymember(const std::string& key, const std::string& member, double radius, geo_unit unit, bool with_coord, bool with_dist, bool with_hash, bool asc_order, std::size_t count, const std::string& store_key, const std::string& storedist_key, const reply_callback_t& reply_callback);
703  std::future<reply> georadiusbymember(const std::string& key, const std::string& member, double radius, geo_unit unit, bool with_coord = false, bool with_dist = false, bool with_hash = false, bool asc_order = false, std::size_t count = 0, const std::string& store_key = "", const std::string& storedist_key = "");
704 
705  client& get(const std::string& key, const reply_callback_t& reply_callback);
706  std::future<reply> get(const std::string& key);
707 
708  client& getbit(const std::string& key, int offset, const reply_callback_t& reply_callback);
709  std::future<reply> getbit(const std::string& key, int offset);
710 
711  client& getrange(const std::string& key, int start, int end, const reply_callback_t& reply_callback);
712  std::future<reply> getrange(const std::string& key, int start, int end);
713 
714  client& getset(const std::string& key, const std::string& val, const reply_callback_t& reply_callback);
715  std::future<reply> getset(const std::string& key, const std::string& val);
716 
717  client& hdel(const std::string& key, const std::vector<std::string>& fields, const reply_callback_t& reply_callback);
718  std::future<reply> hdel(const std::string& key, const std::vector<std::string>& fields);
719 
720  client& hexists(const std::string& key, const std::string& field, const reply_callback_t& reply_callback);
721  std::future<reply> hexists(const std::string& key, const std::string& field);
722 
723  client& hget(const std::string& key, const std::string& field, const reply_callback_t& reply_callback);
724  std::future<reply> hget(const std::string& key, const std::string& field);
725 
726  client& hgetall(const std::string& key, const reply_callback_t& reply_callback);
727  std::future<reply> hgetall(const std::string& key);
728 
729  client& hincrby(const std::string& key, const std::string& field, int incr, const reply_callback_t& reply_callback);
730  std::future<reply> hincrby(const std::string& key, const std::string& field, int incr);
731 
732  client& hincrbyfloat(const std::string& key, const std::string& field, float incr, const reply_callback_t& reply_callback);
733  std::future<reply> hincrbyfloat(const std::string& key, const std::string& field, float incr);
734 
735  client& hkeys(const std::string& key, const reply_callback_t& reply_callback);
736  std::future<reply> hkeys(const std::string& key);
737 
738  client& hlen(const std::string& key, const reply_callback_t& reply_callback);
739  std::future<reply> hlen(const std::string& key);
740 
741  client& hmget(const std::string& key, const std::vector<std::string>& fields, const reply_callback_t& reply_callback);
742  std::future<reply> hmget(const std::string& key, const std::vector<std::string>& fields);
743 
744  client& hmset(const std::string& key, const std::vector<std::pair<std::string, std::string>>& field_val, const reply_callback_t& reply_callback);
745  std::future<reply> hmset(const std::string& key, const std::vector<std::pair<std::string, std::string>>& field_val);
746 
747  client& hscan(const std::string& key, std::size_t cursor, const reply_callback_t& reply_callback);
748  std::future<reply> hscan(const std::string& key, std::size_t cursor);
749 
750  client& hscan(const std::string& key, std::size_t cursor, const std::string& pattern, const reply_callback_t& reply_callback);
751  std::future<reply> hscan(const std::string& key, std::size_t cursor, const std::string& pattern);
752 
753  client& hscan(const std::string& key, std::size_t cursor, std::size_t count, const reply_callback_t& reply_callback);
754  std::future<reply> hscan(const std::string& key, std::size_t cursor, std::size_t count);
755 
756  client& hscan(const std::string& key, std::size_t cursor, const std::string& pattern, std::size_t count, const reply_callback_t& reply_callback);
757  std::future<reply> hscan(const std::string& key, std::size_t cursor, const std::string& pattern, std::size_t count);
758 
759  client& hset(const std::string& key, const std::string& field, const std::string& value, const reply_callback_t& reply_callback);
760  std::future<reply> hset(const std::string& key, const std::string& field, const std::string& value);
761 
762  client& hsetnx(const std::string& key, const std::string& field, const std::string& value, const reply_callback_t& reply_callback);
763  std::future<reply> hsetnx(const std::string& key, const std::string& field, const std::string& value);
764 
765  client& hstrlen(const std::string& key, const std::string& field, const reply_callback_t& reply_callback);
766  std::future<reply> hstrlen(const std::string& key, const std::string& field);
767 
768  client& hvals(const std::string& key, const reply_callback_t& reply_callback);
769  std::future<reply> hvals(const std::string& key);
770 
771  client& incr(const std::string& key, const reply_callback_t& reply_callback);
772  std::future<reply> incr(const std::string& key);
773 
774  client& incrby(const std::string& key, int incr, const reply_callback_t& reply_callback);
775  std::future<reply> incrby(const std::string& key, int incr);
776 
777  client& incrbyfloat(const std::string& key, float incr, const reply_callback_t& reply_callback);
778  std::future<reply> incrbyfloat(const std::string& key, float incr);
779 
780  client& info(const reply_callback_t& reply_callback);
781  client& info(const std::string& section, const reply_callback_t& reply_callback);
782  std::future<reply> info(const std::string& section = "default");
783 
784  client& keys(const std::string& pattern, const reply_callback_t& reply_callback);
785  std::future<reply> keys(const std::string& pattern);
786 
787  client& lastsave(const reply_callback_t& reply_callback);
788  std::future<reply> lastsave();
789 
790  client& lindex(const std::string& key, int index, const reply_callback_t& reply_callback);
791  std::future<reply> lindex(const std::string& key, int index);
792 
793  client& linsert(const std::string& key, const std::string& before_after, const std::string& pivot, const std::string& value, const reply_callback_t& reply_callback);
794  std::future<reply> linsert(const std::string& key, const std::string& before_after, const std::string& pivot, const std::string& value);
795 
796  client& llen(const std::string& key, const reply_callback_t& reply_callback);
797  std::future<reply> llen(const std::string& key);
798 
799  client& lpop(const std::string& key, const reply_callback_t& reply_callback);
800  std::future<reply> lpop(const std::string& key);
801 
802  client& lpush(const std::string& key, const std::vector<std::string>& values, const reply_callback_t& reply_callback);
803  std::future<reply> lpush(const std::string& key, const std::vector<std::string>& values);
804 
805  client& lpushx(const std::string& key, const std::string& value, const reply_callback_t& reply_callback);
806  std::future<reply> lpushx(const std::string& key, const std::string& value);
807 
808  client& lrange(const std::string& key, int start, int stop, const reply_callback_t& reply_callback);
809  std::future<reply> lrange(const std::string& key, int start, int stop);
810 
811  client& lrem(const std::string& key, int count, const std::string& value, const reply_callback_t& reply_callback);
812  std::future<reply> lrem(const std::string& key, int count, const std::string& value);
813 
814  client& lset(const std::string& key, int index, const std::string& value, const reply_callback_t& reply_callback);
815  std::future<reply> lset(const std::string& key, int index, const std::string& value);
816 
817  client& ltrim(const std::string& key, int start, int stop, const reply_callback_t& reply_callback);
818  std::future<reply> ltrim(const std::string& key, int start, int stop);
819 
820  client& mget(const std::vector<std::string>& keys, const reply_callback_t& reply_callback);
821  std::future<reply> mget(const std::vector<std::string>& keys);
822 
823  client& migrate(const std::string& host, int port, const std::string& key, const std::string& dest_db, int timeout, const reply_callback_t& reply_callback);
824  client& migrate(const std::string& host, int port, const std::string& key, const std::string& dest_db, int timeout, bool copy, bool replace, const std::vector<std::string>& keys, const reply_callback_t& reply_callback);
825  std::future<reply> migrate(const std::string& host, int port, const std::string& key, const std::string& dest_db, int timeout, bool copy = false, bool replace = false, const std::vector<std::string>& keys = {});
826 
827  client& monitor(const reply_callback_t& reply_callback);
828  std::future<reply> monitor();
829 
830  client& move(const std::string& key, const std::string& db, const reply_callback_t& reply_callback);
831  std::future<reply> move(const std::string& key, const std::string& db);
832 
833  client& mset(const std::vector<std::pair<std::string, std::string>>& key_vals, const reply_callback_t& reply_callback);
834  std::future<reply> mset(const std::vector<std::pair<std::string, std::string>>& key_vals);
835 
836  client& msetnx(const std::vector<std::pair<std::string, std::string>>& key_vals, const reply_callback_t& reply_callback);
837  std::future<reply> msetnx(const std::vector<std::pair<std::string, std::string>>& key_vals);
838 
839  client& multi(const reply_callback_t& reply_callback);
840  std::future<reply> multi();
841 
842  client& object(const std::string& subcommand, const std::vector<std::string>& args, const reply_callback_t& reply_callback);
843  std::future<reply> object(const std::string& subcommand, const std::vector<std::string>& args);
844 
845  client& persist(const std::string& key, const reply_callback_t& reply_callback);
846  std::future<reply> persist(const std::string& key);
847 
848  client& pexpire(const std::string& key, int milliseconds, const reply_callback_t& reply_callback);
849  std::future<reply> pexpire(const std::string& key, int milliseconds);
850 
851  client& pexpireat(const std::string& key, int milliseconds_timestamp, const reply_callback_t& reply_callback);
852  std::future<reply> pexpireat(const std::string& key, int milliseconds_timestamp);
853 
854  client& pfadd(const std::string& key, const std::vector<std::string>& elements, const reply_callback_t& reply_callback);
855  std::future<reply> pfadd(const std::string& key, const std::vector<std::string>& elements);
856 
857  client& pfcount(const std::vector<std::string>& keys, const reply_callback_t& reply_callback);
858  std::future<reply> pfcount(const std::vector<std::string>& keys);
859 
860  client& pfmerge(const std::string& destkey, const std::vector<std::string>& sourcekeys, const reply_callback_t& reply_callback);
861  std::future<reply> pfmerge(const std::string& destkey, const std::vector<std::string>& sourcekeys);
862 
863  client& ping(const reply_callback_t& reply_callback);
864  std::future<reply> ping();
865 
866  client& ping(const std::string& message, const reply_callback_t& reply_callback);
867  std::future<reply> ping(const std::string& message);
868 
869  client& psetex(const std::string& key, int milliseconds, const std::string& val, const reply_callback_t& reply_callback);
870  std::future<reply> psetex(const std::string& key, int milliseconds, const std::string& val);
871 
872  client& publish(const std::string& channel, const std::string& message, const reply_callback_t& reply_callback);
873  std::future<reply> publish(const std::string& channel, const std::string& message);
874 
875  client& pubsub(const std::string& subcommand, const std::vector<std::string>& args, const reply_callback_t& reply_callback);
876  std::future<reply> pubsub(const std::string& subcommand, const std::vector<std::string>& args);
877 
878  client& pttl(const std::string& key, const reply_callback_t& reply_callback);
879  std::future<reply> pttl(const std::string& key);
880 
881  client& quit(const reply_callback_t& reply_callback);
882  std::future<reply> quit();
883 
884  client& randomkey(const reply_callback_t& reply_callback);
885  std::future<reply> randomkey();
886 
887  client& readonly(const reply_callback_t& reply_callback);
888  std::future<reply> readonly();
889 
890  client& readwrite(const reply_callback_t& reply_callback);
891  std::future<reply> readwrite();
892 
893  client& rename(const std::string& key, const std::string& newkey, const reply_callback_t& reply_callback);
894  std::future<reply> rename(const std::string& key, const std::string& newkey);
895 
896  client& renamenx(const std::string& key, const std::string& newkey, const reply_callback_t& reply_callback);
897  std::future<reply> renamenx(const std::string& key, const std::string& newkey);
898 
899  client& restore(const std::string& key, int ttl, const std::string& serialized_value, const reply_callback_t& reply_callback);
900  std::future<reply> restore(const std::string& key, int ttl, const std::string& serialized_value);
901 
902  client& restore(const std::string& key, int ttl, const std::string& serialized_value, const std::string& replace, const reply_callback_t& reply_callback);
903  std::future<reply> restore(const std::string& key, int ttl, const std::string& serialized_value, const std::string& replace);
904 
905  client& role(const reply_callback_t& reply_callback);
906  std::future<reply> role();
907 
908  client& rpop(const std::string& key, const reply_callback_t& reply_callback);
909  std::future<reply> rpop(const std::string& key);
910 
911  client& rpoplpush(const std::string& source, const std::string& destination, const reply_callback_t& reply_callback);
912  std::future<reply> rpoplpush(const std::string& src, const std::string& dst);
913 
914  client& rpush(const std::string& key, const std::vector<std::string>& values, const reply_callback_t& reply_callback);
915  std::future<reply> rpush(const std::string& key, const std::vector<std::string>& values);
916 
917  client& rpushx(const std::string& key, const std::string& value, const reply_callback_t& reply_callback);
918  std::future<reply> rpushx(const std::string& key, const std::string& value);
919 
920  client& sadd(const std::string& key, const std::vector<std::string>& members, const reply_callback_t& reply_callback);
921  std::future<reply> sadd(const std::string& key, const std::vector<std::string>& members);
922 
923  client& save(const reply_callback_t& reply_callback);
924  std::future<reply> save();
925 
926  client& scan(std::size_t cursor, const reply_callback_t& reply_callback);
927  std::future<reply> scan(std::size_t cursor);
928 
929  client& scan(std::size_t cursor, const std::string& pattern, const reply_callback_t& reply_callback);
930  std::future<reply> scan(std::size_t cursor, const std::string& pattern);
931 
932  client& scan(std::size_t cursor, std::size_t count, const reply_callback_t& reply_callback);
933  std::future<reply> scan(std::size_t cursor, std::size_t count);
934 
935  client& scan(std::size_t cursor, const std::string& pattern, std::size_t count, const reply_callback_t& reply_callback);
936  std::future<reply> scan(std::size_t cursor, const std::string& pattern, std::size_t count);
937 
938  client& scard(const std::string& key, const reply_callback_t& reply_callback);
939  std::future<reply> scard(const std::string& key);
940 
941  client& script_debug(const std::string& mode, const reply_callback_t& reply_callback);
942  std::future<reply> script_debug(const std::string& mode);
943 
944  client& script_exists(const std::vector<std::string>& scripts, const reply_callback_t& reply_callback);
945  std::future<reply> script_exists(const std::vector<std::string>& scripts);
946 
947  client& script_flush(const reply_callback_t& reply_callback);
948  std::future<reply> script_flush();
949 
950  client& script_kill(const reply_callback_t& reply_callback);
951  std::future<reply> script_kill();
952 
953  client& script_load(const std::string& script, const reply_callback_t& reply_callback);
954  std::future<reply> script_load(const std::string& script);
955 
956  client& sdiff(const std::vector<std::string>& keys, const reply_callback_t& reply_callback);
957  std::future<reply> sdiff(const std::vector<std::string>& keys);
958 
959  client& sdiffstore(const std::string& destination, const std::vector<std::string>& keys, const reply_callback_t& reply_callback);
960  std::future<reply> sdiffstore(const std::string& dst, const std::vector<std::string>& keys);
961 
962  client& select(int index, const reply_callback_t& reply_callback);
963  std::future<reply> select(int index);
964 
965  client& set(const std::string& key, const std::string& value, const reply_callback_t& reply_callback);
966  std::future<reply> set(const std::string& key, const std::string& value);
967 
968  client& set_advanced(const std::string& key, const std::string& value, const reply_callback_t& reply_callback);
969  client& set_advanced(const std::string& key, const std::string& value, bool ex, int ex_sec, bool px, int px_milli, bool nx, bool xx, const reply_callback_t& reply_callback);
970  std::future<reply> set_advanced(const std::string& key, const std::string& value, bool ex = false, int ex_sec = 0, bool px = false, int px_milli = 0, bool nx = false, bool xx = false);
971 
972  client& setbit_(const std::string& key, int offset, const std::string& value, const reply_callback_t& reply_callback);
973  std::future<reply> setbit_(const std::string& key, int offset, const std::string& value);
974 
975  client& setex(const std::string& key, int seconds, const std::string& value, const reply_callback_t& reply_callback);
976  std::future<reply> setex(const std::string& key, int seconds, const std::string& value);
977 
978  client& setnx(const std::string& key, const std::string& value, const reply_callback_t& reply_callback);
979  std::future<reply> setnx(const std::string& key, const std::string& value);
980 
981  client& setrange(const std::string& key, int offset, const std::string& value, const reply_callback_t& reply_callback);
982  std::future<reply> setrange(const std::string& key, int offset, const std::string& value);
983 
984  client& shutdown(const reply_callback_t& reply_callback);
985  std::future<reply> shutdown();
986 
987  client& shutdown(const std::string& save, const reply_callback_t& reply_callback);
988  std::future<reply> shutdown(const std::string& save);
989 
990  client& sinter(const std::vector<std::string>& keys, const reply_callback_t& reply_callback);
991  std::future<reply> sinter(const std::vector<std::string>& keys);
992 
993  client& sinterstore(const std::string& destination, const std::vector<std::string>& keys, const reply_callback_t& reply_callback);
994  std::future<reply> sinterstore(const std::string& dst, const std::vector<std::string>& keys);
995 
996  client& sismember(const std::string& key, const std::string& member, const reply_callback_t& reply_callback);
997  std::future<reply> sismember(const std::string& key, const std::string& member);
998 
999  client& slaveof(const std::string& host, int port, const reply_callback_t& reply_callback);
1000  std::future<reply> slaveof(const std::string& host, int port);
1001 
1002  client& slowlog(const std::string subcommand, const reply_callback_t& reply_callback);
1003  std::future<reply> slowlog(const std::string& subcommand);
1004 
1005  client& slowlog(const std::string subcommand, const std::string& argument, const reply_callback_t& reply_callback);
1006  std::future<reply> slowlog(const std::string& subcommand, const std::string& argument);
1007 
1008  client& smembers(const std::string& key, const reply_callback_t& reply_callback);
1009  std::future<reply> smembers(const std::string& key);
1010 
1011  client& smove(const std::string& source, const std::string& destination, const std::string& member, const reply_callback_t& reply_callback);
1012  std::future<reply> smove(const std::string& src, const std::string& dst, const std::string& member);
1013 
1014  client& sort(const std::string& key, const reply_callback_t& reply_callback);
1015  std::future<reply> sort(const std::string& key);
1016 
1017  client& sort(const std::string& key, const std::vector<std::string>& get_patterns, bool asc_order, bool alpha, const reply_callback_t& reply_callback);
1018  std::future<reply> sort(const std::string& key, const std::vector<std::string>& get_patterns, bool asc_order, bool alpha);
1019 
1020  client& sort(const std::string& key, std::size_t offset, std::size_t count, const std::vector<std::string>& get_patterns, bool asc_order, bool alpha, const reply_callback_t& reply_callback);
1021  std::future<reply> sort(const std::string& key, std::size_t offset, std::size_t count, const std::vector<std::string>& get_patterns, bool asc_order, bool alpha);
1022 
1023  client& sort(const std::string& key, const std::string& by_pattern, const std::vector<std::string>& get_patterns, bool asc_order, bool alpha, const reply_callback_t& reply_callback);
1024  std::future<reply> sort(const std::string& key, const std::string& by_pattern, const std::vector<std::string>& get_patterns, bool asc_order, bool alpha);
1025 
1026  client& sort(const std::string& key, const std::vector<std::string>& get_patterns, bool asc_order, bool alpha, const std::string& store_dest, const reply_callback_t& reply_callback);
1027  std::future<reply> sort(const std::string& key, const std::vector<std::string>& get_patterns, bool asc_order, bool alpha, const std::string& store_dest);
1028 
1029  client& sort(const std::string& key, std::size_t offset, std::size_t count, const std::vector<std::string>& get_patterns, bool asc_order, bool alpha, const std::string& store_dest, const reply_callback_t& reply_callback);
1030  std::future<reply> sort(const std::string& key, std::size_t offset, std::size_t count, const std::vector<std::string>& get_patterns, bool asc_order, bool alpha, const std::string& store_dest);
1031 
1032  client& sort(const std::string& key, const std::string& by_pattern, const std::vector<std::string>& get_patterns, bool asc_order, bool alpha, const std::string& store_dest, const reply_callback_t& reply_callback);
1033  std::future<reply> sort(const std::string& key, const std::string& by_pattern, const std::vector<std::string>& get_patterns, bool asc_order, bool alpha, const std::string& store_dest);
1034 
1035  client& sort(const std::string& key, const std::string& by_pattern, std::size_t offset, std::size_t count, const std::vector<std::string>& get_patterns, bool asc_order, bool alpha, const reply_callback_t& reply_callback);
1036  std::future<reply> sort(const std::string& key, const std::string& by_pattern, std::size_t offset, std::size_t count, const std::vector<std::string>& get_patterns, bool asc_order, bool alpha);
1037 
1038  client& sort(const std::string& key, const std::string& by_pattern, std::size_t offset, std::size_t count, const std::vector<std::string>& get_patterns, bool asc_order, bool alpha, const std::string& store_dest, const reply_callback_t& reply_callback);
1039  std::future<reply> sort(const std::string& key, const std::string& by_pattern, std::size_t offset, std::size_t count, const std::vector<std::string>& get_patterns, bool asc_order, bool alpha, const std::string& store_dest);
1040 
1041  client& spop(const std::string& key, const reply_callback_t& reply_callback);
1042  std::future<reply> spop(const std::string& key);
1043 
1044  client& spop(const std::string& key, int count, const reply_callback_t& reply_callback);
1045  std::future<reply> spop(const std::string& key, int count);
1046 
1047  client& srandmember(const std::string& key, const reply_callback_t& reply_callback);
1048  std::future<reply> srandmember(const std::string& key);
1049 
1050  client& srandmember(const std::string& key, int count, const reply_callback_t& reply_callback);
1051  std::future<reply> srandmember(const std::string& key, int count);
1052 
1053  client& srem(const std::string& key, const std::vector<std::string>& members, const reply_callback_t& reply_callback);
1054  std::future<reply> srem(const std::string& key, const std::vector<std::string>& members);
1055 
1056  client& sscan(const std::string& key, std::size_t cursor, const reply_callback_t& reply_callback);
1057  std::future<reply> sscan(const std::string& key, std::size_t cursor);
1058 
1059  client& sscan(const std::string& key, std::size_t cursor, const std::string& pattern, const reply_callback_t& reply_callback);
1060  std::future<reply> sscan(const std::string& key, std::size_t cursor, const std::string& pattern);
1061 
1062  client& sscan(const std::string& key, std::size_t cursor, std::size_t count, const reply_callback_t& reply_callback);
1063  std::future<reply> sscan(const std::string& key, std::size_t cursor, std::size_t count);
1064 
1065  client& sscan(const std::string& key, std::size_t cursor, const std::string& pattern, std::size_t count, const reply_callback_t& reply_callback);
1066  std::future<reply> sscan(const std::string& key, std::size_t cursor, const std::string& pattern, std::size_t count);
1067 
1068  client& strlen(const std::string& key, const reply_callback_t& reply_callback);
1069  std::future<reply> strlen(const std::string& key);
1070 
1071  client& sunion(const std::vector<std::string>& keys, const reply_callback_t& reply_callback);
1072  std::future<reply> sunion(const std::vector<std::string>& keys);
1073 
1074  client& sunionstore(const std::string& destination, const std::vector<std::string>& keys, const reply_callback_t& reply_callback);
1075  std::future<reply> sunionstore(const std::string& dst, const std::vector<std::string>& keys);
1076 
1077  client& sync(const reply_callback_t& reply_callback);
1078  std::future<reply> sync();
1079 
1080  client& time(const reply_callback_t& reply_callback);
1081  std::future<reply> time();
1082 
1083  client& ttl(const std::string& key, const reply_callback_t& reply_callback);
1084  std::future<reply> ttl(const std::string& key);
1085 
1086  client& type(const std::string& key, const reply_callback_t& reply_callback);
1087  std::future<reply> type(const std::string& key);
1088 
1089  client& unwatch(const reply_callback_t& reply_callback);
1090  std::future<reply> unwatch();
1091 
1092  client& wait(int numslaves, int timeout, const reply_callback_t& reply_callback);
1093  std::future<reply> wait(int numslaves, int timeout);
1094 
1095  client& watch(const std::vector<std::string>& keys, const reply_callback_t& reply_callback);
1096  std::future<reply> watch(const std::vector<std::string>& keys);
1097 
1098  client& zadd(const std::string& key, const std::vector<std::string>& options, const std::multimap<std::string, std::string>& score_members, const reply_callback_t& reply_callback);
1099  std::future<reply> zadd(const std::string& key, const std::vector<std::string>& options, const std::multimap<std::string, std::string>& score_members);
1100 
1101  client& zcard(const std::string& key, const reply_callback_t& reply_callback);
1102  std::future<reply> zcard(const std::string& key);
1103 
1104  client& zcount(const std::string& key, int min, int max, const reply_callback_t& reply_callback);
1105  std::future<reply> zcount(const std::string& key, int min, int max);
1106 
1107  client& zcount(const std::string& key, double min, double max, const reply_callback_t& reply_callback);
1108  std::future<reply> zcount(const std::string& key, double min, double max);
1109 
1110  client& zcount(const std::string& key, const std::string& min, const std::string& max, const reply_callback_t& reply_callback);
1111  std::future<reply> zcount(const std::string& key, const std::string& min, const std::string& max);
1112 
1113  client& zincrby(const std::string& key, int incr, const std::string& member, const reply_callback_t& reply_callback);
1114  std::future<reply> zincrby(const std::string& key, int incr, const std::string& member);
1115 
1116  client& zincrby(const std::string& key, double incr, const std::string& member, const reply_callback_t& reply_callback);
1117  std::future<reply> zincrby(const std::string& key, double incr, const std::string& member);
1118 
1119  client& zincrby(const std::string& key, const std::string& incr, const std::string& member, const reply_callback_t& reply_callback);
1120  std::future<reply> zincrby(const std::string& key, const std::string& incr, const std::string& member);
1121 
1122  client& zinterstore(const std::string& destination, std::size_t numkeys, const std::vector<std::string>& keys, const std::vector<std::size_t> weights, aggregate_method method, const reply_callback_t& reply_callback);
1123  std::future<reply> zinterstore(const std::string& destination, std::size_t numkeys, const std::vector<std::string>& keys, const std::vector<std::size_t> weights, aggregate_method method);
1124 
1125  client& zlexcount(const std::string& key, int min, int max, const reply_callback_t& reply_callback);
1126  std::future<reply> zlexcount(const std::string& key, int min, int max);
1127 
1128  client& zlexcount(const std::string& key, double min, double max, const reply_callback_t& reply_callback);
1129  std::future<reply> zlexcount(const std::string& key, double min, double max);
1130 
1131  client& zlexcount(const std::string& key, const std::string& min, const std::string& max, const reply_callback_t& reply_callback);
1132  std::future<reply> zlexcount(const std::string& key, const std::string& min, const std::string& max);
1133 
1134  client& zrange(const std::string& key, int start, int stop, const reply_callback_t& reply_callback);
1135  client& zrange(const std::string& key, int start, int stop, bool withscores, const reply_callback_t& reply_callback);
1136  std::future<reply> zrange(const std::string& key, int start, int stop, bool withscores = false);
1137 
1138  client& zrange(const std::string& key, double start, double stop, const reply_callback_t& reply_callback);
1139  client& zrange(const std::string& key, double start, double stop, bool withscores, const reply_callback_t& reply_callback);
1140  std::future<reply> zrange(const std::string& key, double start, double stop, bool withscores = false);
1141 
1142  client& zrange(const std::string& key, const std::string& start, const std::string& stop, const reply_callback_t& reply_callback);
1143  client& zrange(const std::string& key, const std::string& start, const std::string& stop, bool withscores, const reply_callback_t& reply_callback);
1144  std::future<reply> zrange(const std::string& key, const std::string& start, const std::string& stop, bool withscores = false);
1145 
1146  client& zrangebylex(const std::string& key, int min, int max, const reply_callback_t& reply_callback);
1147  client& zrangebylex(const std::string& key, int min, int max, bool withscores, const reply_callback_t& reply_callback);
1148  std::future<reply> zrangebylex(const std::string& key, int min, int max, bool withscores = false);
1149 
1150  client& zrangebylex(const std::string& key, double min, double max, const reply_callback_t& reply_callback);
1151  client& zrangebylex(const std::string& key, double min, double max, bool withscores, const reply_callback_t& reply_callback);
1152  std::future<reply> zrangebylex(const std::string& key, double min, double max, bool withscores = false);
1153 
1154  client& zrangebylex(const std::string& key, const std::string& min, const std::string& max, const reply_callback_t& reply_callback);
1155  client& zrangebylex(const std::string& key, const std::string& min, const std::string& max, bool withscores, const reply_callback_t& reply_callback);
1156  std::future<reply> zrangebylex(const std::string& key, const std::string& min, const std::string& max, bool withscores = false);
1157 
1158  client& zrangebylex(const std::string& key, int min, int max, std::size_t offset, std::size_t count, const reply_callback_t& reply_callback);
1159  client& zrangebylex(const std::string& key, int min, int max, std::size_t offset, std::size_t count, bool withscores, const reply_callback_t& reply_callback);
1160  std::future<reply> zrangebylex(const std::string& key, int min, int max, std::size_t offset, std::size_t count, bool withscores = false);
1161 
1162  client& zrangebylex(const std::string& key, double min, double max, std::size_t offset, std::size_t count, const reply_callback_t& reply_callback);
1163  client& zrangebylex(const std::string& key, double min, double max, std::size_t offset, std::size_t count, bool withscores, const reply_callback_t& reply_callback);
1164  std::future<reply> zrangebylex(const std::string& key, double min, double max, std::size_t offset, std::size_t count, bool withscores = false);
1165 
1166  client& zrangebylex(const std::string& key, const std::string& min, const std::string& max, std::size_t offset, std::size_t count, const reply_callback_t& reply_callback);
1167  client& zrangebylex(const std::string& key, const std::string& min, const std::string& max, std::size_t offset, std::size_t count, bool withscores, const reply_callback_t& reply_callback);
1168  std::future<reply> zrangebylex(const std::string& key, const std::string& min, const std::string& max, std::size_t offset, std::size_t count, bool withscores = false);
1169 
1170  client& zrangebyscore(const std::string& key, int min, int max, const reply_callback_t& reply_callback);
1171  client& zrangebyscore(const std::string& key, int min, int max, bool withscores, const reply_callback_t& reply_callback);
1172  std::future<reply> zrangebyscore(const std::string& key, int min, int max, bool withscores = false);
1173 
1174  client& zrangebyscore(const std::string& key, double min, double max, const reply_callback_t& reply_callback);
1175  client& zrangebyscore(const std::string& key, double min, double max, bool withscores, const reply_callback_t& reply_callback);
1176  std::future<reply> zrangebyscore(const std::string& key, double min, double max, bool withscores = false);
1177 
1178  client& zrangebyscore(const std::string& key, const std::string& min, const std::string& max, const reply_callback_t& reply_callback);
1179  client& zrangebyscore(const std::string& key, const std::string& min, const std::string& max, bool withscores, const reply_callback_t& reply_callback);
1180  std::future<reply> zrangebyscore(const std::string& key, const std::string& min, const std::string& max, bool withscores = false);
1181 
1182  client& zrangebyscore(const std::string& key, int min, int max, std::size_t offset, std::size_t count, const reply_callback_t& reply_callback);
1183  client& zrangebyscore(const std::string& key, int min, int max, std::size_t offset, std::size_t count, bool withscores, const reply_callback_t& reply_callback);
1184  std::future<reply> zrangebyscore(const std::string& key, int min, int max, std::size_t offset, std::size_t count, bool withscores = false);
1185 
1186  client& zrangebyscore(const std::string& key, double min, double max, std::size_t offset, std::size_t count, const reply_callback_t& reply_callback);
1187  client& zrangebyscore(const std::string& key, double min, double max, std::size_t offset, std::size_t count, bool withscores, const reply_callback_t& reply_callback);
1188  std::future<reply> zrangebyscore(const std::string& key, double min, double max, std::size_t offset, std::size_t count, bool withscores = false);
1189 
1190  client& zrangebyscore(const std::string& key, const std::string& min, const std::string& max, std::size_t offset, std::size_t count, const reply_callback_t& reply_callback);
1191  client& zrangebyscore(const std::string& key, const std::string& min, const std::string& max, std::size_t offset, std::size_t count, bool withscores, const reply_callback_t& reply_callback);
1192  std::future<reply> zrangebyscore(const std::string& key, const std::string& min, const std::string& max, std::size_t offset, std::size_t count, bool withscores = false);
1193 
1194  client& zrank(const std::string& key, const std::string& member, const reply_callback_t& reply_callback);
1195  std::future<reply> zrank(const std::string& key, const std::string& member);
1196 
1197  client& zrem(const std::string& key, const std::vector<std::string>& members, const reply_callback_t& reply_callback);
1198  std::future<reply> zrem(const std::string& key, const std::vector<std::string>& members);
1199 
1200  client& zremrangebylex(const std::string& key, int min, int max, const reply_callback_t& reply_callback);
1201  std::future<reply> zremrangebylex(const std::string& key, int min, int max);
1202 
1203  client& zremrangebylex(const std::string& key, double min, double max, const reply_callback_t& reply_callback);
1204  std::future<reply> zremrangebylex(const std::string& key, double min, double max);
1205 
1206  client& zremrangebylex(const std::string& key, const std::string& min, const std::string& max, const reply_callback_t& reply_callback);
1207  std::future<reply> zremrangebylex(const std::string& key, const std::string& min, const std::string& max);
1208 
1209  client& zremrangebyrank(const std::string& key, int start, int stop, const reply_callback_t& reply_callback);
1210  std::future<reply> zremrangebyrank(const std::string& key, int start, int stop);
1211 
1212  client& zremrangebyrank(const std::string& key, double start, double stop, const reply_callback_t& reply_callback);
1213  std::future<reply> zremrangebyrank(const std::string& key, double start, double stop);
1214 
1215  client& zremrangebyrank(const std::string& key, const std::string& start, const std::string& stop, const reply_callback_t& reply_callback);
1216  std::future<reply> zremrangebyrank(const std::string& key, const std::string& start, const std::string& stop);
1217 
1218  client& zremrangebyscore(const std::string& key, int min, int max, const reply_callback_t& reply_callback);
1219  std::future<reply> zremrangebyscore(const std::string& key, int min, int max);
1220 
1221  client& zremrangebyscore(const std::string& key, double min, double max, const reply_callback_t& reply_callback);
1222  std::future<reply> zremrangebyscore(const std::string& key, double min, double max);
1223 
1224  client& zremrangebyscore(const std::string& key, const std::string& min, const std::string& max, const reply_callback_t& reply_callback);
1225  std::future<reply> zremrangebyscore(const std::string& key, const std::string& min, const std::string& max);
1226 
1227  client& zrevrange(const std::string& key, int start, int stop, const reply_callback_t& reply_callback);
1228  client& zrevrange(const std::string& key, int start, int stop, bool withscores, const reply_callback_t& reply_callback);
1229  std::future<reply> zrevrange(const std::string& key, int start, int stop, bool withscores = false);
1230 
1231  client& zrevrange(const std::string& key, double start, double stop, const reply_callback_t& reply_callback);
1232  client& zrevrange(const std::string& key, double start, double stop, bool withscores, const reply_callback_t& reply_callback);
1233  std::future<reply> zrevrange(const std::string& key, double start, double stop, bool withscores = false);
1234 
1235  client& zrevrange(const std::string& key, const std::string& start, const std::string& stop, const reply_callback_t& reply_callback);
1236  client& zrevrange(const std::string& key, const std::string& start, const std::string& stop, bool withscores, const reply_callback_t& reply_callback);
1237  std::future<reply> zrevrange(const std::string& key, const std::string& start, const std::string& stop, bool withscores = false);
1238 
1239  client& zrevrangebylex(const std::string& key, int max, int min, const reply_callback_t& reply_callback);
1240  client& zrevrangebylex(const std::string& key, int max, int min, bool withscores, const reply_callback_t& reply_callback);
1241  std::future<reply> zrevrangebylex(const std::string& key, int max, int min, bool withscores = false);
1242 
1243  client& zrevrangebylex(const std::string& key, double max, double min, const reply_callback_t& reply_callback);
1244  client& zrevrangebylex(const std::string& key, double max, double min, bool withscores, const reply_callback_t& reply_callback);
1245  std::future<reply> zrevrangebylex(const std::string& key, double max, double min, bool withscores = false);
1246 
1247  client& zrevrangebylex(const std::string& key, const std::string& max, const std::string& min, const reply_callback_t& reply_callback);
1248  client& zrevrangebylex(const std::string& key, const std::string& max, const std::string& min, bool withscores, const reply_callback_t& reply_callback);
1249  std::future<reply> zrevrangebylex(const std::string& key, const std::string& max, const std::string& min, bool withscores = false);
1250 
1251  client& zrevrangebylex(const std::string& key, int max, int min, std::size_t offset, std::size_t count, const reply_callback_t& reply_callback);
1252  client& zrevrangebylex(const std::string& key, int max, int min, std::size_t offset, std::size_t count, bool withscores, const reply_callback_t& reply_callback);
1253  std::future<reply> zrevrangebylex(const std::string& key, int max, int min, std::size_t offset, std::size_t count, bool withscores = false);
1254 
1255  client& zrevrangebylex(const std::string& key, double max, double min, std::size_t offset, std::size_t count, const reply_callback_t& reply_callback);
1256  client& zrevrangebylex(const std::string& key, double max, double min, std::size_t offset, std::size_t count, bool withscores, const reply_callback_t& reply_callback);
1257  std::future<reply> zrevrangebylex(const std::string& key, double max, double min, std::size_t offset, std::size_t count, bool withscores = false);
1258 
1259  client& zrevrangebylex(const std::string& key, const std::string& max, const std::string& min, std::size_t offset, std::size_t count, const reply_callback_t& reply_callback);
1260  client& zrevrangebylex(const std::string& key, const std::string& max, const std::string& min, std::size_t offset, std::size_t count, bool withscores, const reply_callback_t& reply_callback);
1261  std::future<reply> zrevrangebylex(const std::string& key, const std::string& max, const std::string& min, std::size_t offset, std::size_t count, bool withscores = false);
1262 
1263  client& zrevrangebyscore(const std::string& key, int max, int min, const reply_callback_t& reply_callback);
1264  client& zrevrangebyscore(const std::string& key, int max, int min, bool withscores, const reply_callback_t& reply_callback);
1265  std::future<reply> zrevrangebyscore(const std::string& key, int max, int min, bool withscores = false);
1266 
1267  client& zrevrangebyscore(const std::string& key, double max, double min, const reply_callback_t& reply_callback);
1268  client& zrevrangebyscore(const std::string& key, double max, double min, bool withscores, const reply_callback_t& reply_callback);
1269  std::future<reply> zrevrangebyscore(const std::string& key, double max, double min, bool withscores = false);
1270 
1271  client& zrevrangebyscore(const std::string& key, const std::string& max, const std::string& min, const reply_callback_t& reply_callback);
1272  client& zrevrangebyscore(const std::string& key, const std::string& max, const std::string& min, bool withscores, const reply_callback_t& reply_callback);
1273  std::future<reply> zrevrangebyscore(const std::string& key, const std::string& max, const std::string& min, bool withscores = false);
1274 
1275  client& zrevrangebyscore(const std::string& key, int max, int min, std::size_t offset, std::size_t count, const reply_callback_t& reply_callback);
1276  client& zrevrangebyscore(const std::string& key, int max, int min, std::size_t offset, std::size_t count, bool withscores, const reply_callback_t& reply_callback);
1277  std::future<reply> zrevrangebyscore(const std::string& key, int max, int min, std::size_t offset, std::size_t count, bool withscores = false);
1278 
1279  client& zrevrangebyscore(const std::string& key, double max, double min, std::size_t offset, std::size_t count, const reply_callback_t& reply_callback);
1280  client& zrevrangebyscore(const std::string& key, double max, double min, std::size_t offset, std::size_t count, bool withscores, const reply_callback_t& reply_callback);
1281  std::future<reply> zrevrangebyscore(const std::string& key, double max, double min, std::size_t offset, std::size_t count, bool withscores = false);
1282 
1283  client& zrevrangebyscore(const std::string& key, const std::string& max, const std::string& min, std::size_t offset, std::size_t count, const reply_callback_t& reply_callback);
1284  client& zrevrangebyscore(const std::string& key, const std::string& max, const std::string& min, std::size_t offset, std::size_t count, bool withscores, const reply_callback_t& reply_callback);
1285  std::future<reply> zrevrangebyscore(const std::string& key, const std::string& max, const std::string& min, std::size_t offset, std::size_t count, bool withscores = false);
1286 
1287  client& zrevrank(const std::string& key, const std::string& member, const reply_callback_t& reply_callback);
1288  std::future<reply> zrevrank(const std::string& key, const std::string& member);
1289 
1290  client& zscan(const std::string& key, std::size_t cursor, const reply_callback_t& reply_callback);
1291  std::future<reply> zscan(const std::string& key, std::size_t cursor);
1292 
1293  client& zscan(const std::string& key, std::size_t cursor, const std::string& pattern, const reply_callback_t& reply_callback);
1294  std::future<reply> zscan(const std::string& key, std::size_t cursor, const std::string& pattern);
1295 
1296  client& zscan(const std::string& key, std::size_t cursor, std::size_t count, const reply_callback_t& reply_callback);
1297  std::future<reply> zscan(const std::string& key, std::size_t cursor, std::size_t count);
1298 
1299  client& zscan(const std::string& key, std::size_t cursor, const std::string& pattern, std::size_t count, const reply_callback_t& reply_callback);
1300  std::future<reply> zscan(const std::string& key, std::size_t cursor, const std::string& pattern, std::size_t count);
1301 
1302  client& zscore(const std::string& key, const std::string& member, const reply_callback_t& reply_callback);
1303  std::future<reply> zscore(const std::string& key, const std::string& member);
1304 
1305  client& zunionstore(const std::string& destination, std::size_t numkeys, const std::vector<std::string>& keys, const std::vector<std::size_t> weights, aggregate_method method, const reply_callback_t& reply_callback);
1306  std::future<reply> zunionstore(const std::string& destination, std::size_t numkeys, const std::vector<std::string>& keys, const std::vector<std::size_t> weights, aggregate_method method);
1307 
1308 private:
1310  template <typename T>
1311  typename std::enable_if<std::is_same<T, client_type>::value>::type
1312  client_kill_unpack_arg(std::vector<std::string>& redis_cmd, reply_callback_t&, client_type type);
1313 
1314  template <typename T>
1315  typename std::enable_if<std::is_same<T, bool>::value>::type
1316  client_kill_unpack_arg(std::vector<std::string>& redis_cmd, reply_callback_t&, bool skip);
1317 
1318  template <typename T>
1319  typename std::enable_if<std::is_integral<T>::value>::type
1320  client_kill_unpack_arg(std::vector<std::string>& redis_cmd, reply_callback_t&, uint64_t id);
1321 
1322  template <typename T>
1323  typename std::enable_if<std::is_class<T>::value>::type
1324  client_kill_unpack_arg(std::vector<std::string>&, reply_callback_t& reply_callback, const T& cb);
1325 
1326  template <typename T, typename... Ts>
1327  void
1328  client_kill_impl(std::vector<std::string>& redis_cmd, reply_callback_t& reply, const T& arg, const Ts&... args);
1329 
1330  template <typename T>
1331  void
1332  client_kill_impl(std::vector<std::string>& redis_cmd, reply_callback_t& reply, const T& arg);
1333 
1334 private:
1336  client& sort(const std::string& key, const std::string& by_pattern, bool limit, std::size_t offset, std::size_t count, const std::vector<std::string>& get_patterns, bool asc_order, bool alpha, const std::string& store_dest, const reply_callback_t& reply_callback);
1337 
1339  client& zrevrangebyscore(const std::string& key, const std::string& max, const std::string& min, bool limit, std::size_t offset, std::size_t count, bool withscores, const reply_callback_t& reply_callback);
1340 
1342  client& zrangebyscore(const std::string& key, const std::string& min, const std::string& max, bool limit, std::size_t offset, std::size_t count, bool withscores, const reply_callback_t& reply_callback);
1343 
1345  client& zrevrangebylex(const std::string& key, const std::string& max, const std::string& min, bool limit, std::size_t offset, std::size_t count, bool withscores, const reply_callback_t& reply_callback);
1346 
1348  client& zrangebylex(const std::string& key, const std::string& min, const std::string& max, bool limit, std::size_t offset, std::size_t count, bool withscores, const reply_callback_t& reply_callback);
1349 
1350 private:
1357  void connection_receive_handler(network::redis_connection& connection, reply& reply);
1358 
1364  void connection_disconnection_handler(network::redis_connection& connection);
1365 
1369  void clear_callbacks(void);
1370 
1375  void try_commit(void);
1376 
1378  std::future<reply> exec_cmd(const std::function<client&(const reply_callback_t&)>& f);
1379 
1380 private:
1384  struct command_request {
1385  std::vector<std::string> command;
1386  reply_callback_t callback;
1387  };
1388 
1389 private:
1393  std::string m_redis_server;
1397  std::size_t m_redis_port = 0;
1401  std::string m_master_name;
1405  std::string m_password;
1409  int m_database_index = 0;
1410 
1414  network::redis_connection m_client;
1415 
1419  cpp_redis::sentinel m_sentinel;
1420 
1424  std::uint32_t m_connect_timeout_msecs = 0;
1428  std::int32_t m_max_reconnects = 0;
1432  std::int32_t m_current_reconnect_attempts = 0;
1436  std::uint32_t m_reconnect_interval_msecs = 0;
1437 
1441  std::atomic_bool m_reconnecting;
1445  std::atomic_bool m_cancel;
1446 
1450  std::queue<command_request> m_commands;
1451 
1455  connect_callback_t m_connect_callback;
1456 
1460  std::mutex m_callbacks_mutex;
1461 
1465  std::condition_variable m_sync_condvar;
1466 
1470  std::atomic<unsigned int> m_callbacks_running;
1471 }; // namespace cpp_redis
1472 
1473 } // namespace cpp_redis
1474 
1475 #include <cpp_redis/impl/client.ipp>
Definition: redis_connection.hpp:45
std::future< reply > client_kill_future(const T, const Ts...)
Definition: client.ipp:122
client(void)
ctor
Definition: client.hpp:48
client & operator=(const client &)=delete
assignment operator
Definition: client.hpp:412
void cancel_reconnect(void)
geo_unit
Definition: client.hpp:352
bitfield_operation_type operation_type
Definition: client.hpp:416
client & client_kill(const std::string &host, int port, const T &arg, const Ts &... args)
Definition: client.ipp:93
Definition: reply.hpp:37
bitfield_operation_type
Definition: client.hpp:393
std::string aggregate_method_to_string(aggregate_method method) const
client & sync_commit(const std::chrono::duration< Rep, Period > &timeout)
Definition: client.hpp:217
std::string geo_unit_to_string(geo_unit unit) const
bool is_reconnecting(void) const
connect_state
Definition: client.hpp:71
std::function< void(reply &)> reply_callback_t
Definition: client.hpp:169
void add_sentinel(const std::string &host, std::size_t port, std::uint32_t timeout_msecs=0)
std::string type
Definition: client.hpp:421
std::string overflow_type_to_string(overflow_type type) const
void disconnect(bool wait_for_removal=false)
client & sync_commit(void)
client & send(const std::vector< std::string > &redis_cmd, const reply_callback_t &callback)
Definition: sentinel.hpp:40
std::string bitfield_operation_type_to_string(bitfield_operation_type operation) const
void clear_sentinels(void)
overflow_type overflow
Definition: client.hpp:436
void connect(const std::string &host="127.0.0.1", std::size_t port=6379, const connect_callback_t &connect_callback=nullptr, std::uint32_t timeout_msecs=0, std::int32_t max_reconnects=0, std::uint32_t reconnect_interval_msecs=0)
const sentinel & get_sentinel(void) const
client_type
Definition: client.hpp:54
std::function< void(const std::string &host, std::size_t port, connect_state status)> connect_callback_t
Definition: client.hpp:106
int offset
Definition: client.hpp:426
overflow_type
Definition: client.hpp:373
int value
Definition: client.hpp:431
~client(void)
dtor
bool is_connected(void) const
client & commit(void)
Definition: array_builder.hpp:29
aggregate_method
Definition: client.hpp:332