42 virtual ~Client() =
default;
44 virtual size_t ShardsCount()
const = 0;
45 virtual bool IsInClusterMode()
const = 0;
47 virtual size_t ShardByKey(
const std::string& key)
const = 0;
49 void CheckShardIdx(size_t shard_idx)
const;
58 virtual RequestAppend Append(std::string key, std::string value,
const CommandControl& command_control) = 0;
60 virtual RequestBitop Bitop(
63 std::vector<std::string> src_keys,
67 virtual RequestDbsize Dbsize(size_t shard,
const CommandControl& command_control) = 0;
69 virtual RequestDecr Decr(std::string key,
const CommandControl& command_control) = 0;
71 virtual RequestDel Del(std::string key,
const CommandControl& command_control) = 0;
73 virtual RequestDel Del(std::vector<std::string> keys,
const CommandControl& command_control) = 0;
75 virtual RequestUnlink Unlink(std::string key,
const CommandControl& command_control) = 0;
77 virtual RequestUnlink Unlink(std::vector<std::string> keys,
const CommandControl& command_control) = 0;
85 template <
typename ScriptResult,
typename ReplyType = ScriptResult>
86 RequestEval<ScriptResult, ReplyType>
Eval(
88 std::vector<std::string> keys,
89 std::vector<std::string> args,
92 return RequestEval<ScriptResult, ReplyType>{
93 EvalCommon(std::move(script), std::move(keys), std::move(args), command_control)
104 template <
typename ScriptResult,
typename ReplyType = ScriptResult>
105 RequestEvalSha<ScriptResult, ReplyType>
EvalSha(
106 std::string script_hash,
107 std::vector<std::string> keys,
108 std::vector<std::string> args,
111 return RequestEvalSha<ScriptResult, ReplyType>{
112 EvalShaCommon(std::move(script_hash), std::move(keys), std::move(args), command_control)
122 template <
typename ScriptResult,
typename ReplyType = ScriptResult>
125 std::vector<std::string> keys,
126 std::vector<std::string> args,
129 return RequestEval<ScriptResult, ReplyType>{
130 EvalReadOnlyCommon(std::move(script), std::move(keys), std::move(args), command_control)
140 template <
typename ScriptResult,
typename ReplyType = ScriptResult>
142 std::string script_hash,
143 std::vector<std::string> keys,
144 std::vector<std::string> args,
147 return RequestEvalSha<ScriptResult, ReplyType>{
148 EvalShaReadOnlyCommon(std::move(script_hash), std::move(keys), std::move(args), command_control)
160 template <
typename ReplyType>
163 std::vector<std::string> args,
167 return RequestGeneric<ReplyType>{GenericCommon(std::move(command), std::move(args), key_index, command_control)
178 template <
typename ScriptInfo,
typename ReplyType = std::decay_t<ScriptInfo>>
179 RequestEval<std::decay_t<ScriptInfo>, ReplyType>
Eval(
180 const ScriptInfo& script_info,
181 std::vector<std::string> keys,
182 std::vector<std::string> args,
185 return RequestEval<std::decay_t<ScriptInfo>, ReplyType>{
186 EvalCommon(script_info.GetScript(), std::move(keys), std::move(args), command_control)
190 virtual RequestExists Exists(std::string key,
const CommandControl& command_control) = 0;
192 virtual RequestExists Exists(std::vector<std::string> keys,
const CommandControl& command_control) = 0;
194 virtual RequestExpire Expire(std::string key, std::chrono::seconds ttl,
const CommandControl& command_control) = 0;
196 virtual RequestExpire Expire(
198 std::chrono::seconds ttl,
203 virtual RequestGeoadd Geoadd(std::string key,
GeoaddArg point_member,
const CommandControl& command_control) = 0;
205 virtual RequestGeoadd Geoadd(
211 virtual RequestGeopos Geopos(
213 std::vector<std::string> members,
217 virtual RequestGeoradius Georadius(
226 virtual RequestGeosearch Geosearch(
234 virtual RequestGeosearch Geosearch(
243 virtual RequestGeosearch Geosearch(
252 virtual RequestGeosearch Geosearch(
262 virtual RequestGet Get(std::string key,
const CommandControl& command_control) = 0;
264 virtual RequestGetdel Getdel(std::string key,
const CommandControl& command_control) = 0;
266 virtual RequestGetset Getset(std::string key, std::string value,
const CommandControl& command_control) = 0;
268 virtual RequestHdel Hdel(std::string key, std::string field,
const CommandControl& command_control) = 0;
270 virtual RequestHdel Hdel(
272 std::vector<std::string> fields,
276 virtual RequestHexists Hexists(std::string key, std::string field,
const CommandControl& command_control) = 0;
278 virtual RequestHget Hget(std::string key, std::string field,
const CommandControl& command_control) = 0;
281 virtual RequestHgetall Hgetall(std::string key,
const CommandControl& command_control) = 0;
283 virtual RequestHincrby Hincrby(
290 virtual RequestHincrbyfloat Hincrbyfloat(
298 virtual RequestHkeys Hkeys(std::string key,
const CommandControl& command_control) = 0;
300 virtual RequestHlen Hlen(std::string key,
const CommandControl& command_control) = 0;
302 virtual RequestHmget Hmget(
304 std::vector<std::string> fields,
308 virtual RequestHmset Hmset(
310 std::vector<std::pair<std::string, std::string>> field_values,
318 virtual RequestHscan
Hscan(std::string key, HscanOptions options,
const CommandControl& command_control) = 0;
320 virtual RequestHset Hset(
327 virtual RequestHsetnx Hsetnx(
335 virtual RequestHvals Hvals(std::string key,
const CommandControl& command_control) = 0;
337 virtual RequestIncr Incr(std::string key,
const CommandControl& command_control) = 0;
339 [[
deprecated(
"use Scan")]]
virtual RequestKeys Keys(
340 std::string keys_pattern,
345 virtual RequestLindex Lindex(std::string key, int64_t index,
const CommandControl& command_control) = 0;
347 virtual RequestLlen Llen(std::string key,
const CommandControl& command_control) = 0;
349 virtual RequestLpop Lpop(std::string key,
const CommandControl& command_control) = 0;
351 virtual RequestLpush Lpush(std::string key, std::string value,
const CommandControl& command_control) = 0;
353 virtual RequestLpush Lpush(
355 std::vector<std::string> values,
359 virtual RequestLpushx Lpushx(std::string key, std::string element,
const CommandControl& command_control) = 0;
361 virtual RequestLrange Lrange(
368 virtual RequestLrem Lrem(
375 virtual RequestLtrim Ltrim(std::string key, int64_t start, int64_t stop,
const CommandControl& command_control) = 0;
377 virtual RequestMget Mget(std::vector<std::string> keys,
const CommandControl& command_control) = 0;
379 virtual RequestMset Mset(
380 std::vector<std::pair<std::string, std::string>> key_values,
390 std::vector<std::pair<std::string, std::string>> key_values,
400 std::vector<std::pair<std::string, std::string>> key_values,
405 virtual TransactionPtr Multi() = 0;
407 virtual TransactionPtr Multi(
Transaction::CheckShards check_shards) = 0;
409 virtual RequestPersist Persist(std::string key,
const CommandControl& command_control) = 0;
411 virtual RequestPexpire Pexpire(
413 std::chrono::milliseconds ttl,
417 virtual RequestPing Ping(size_t shard,
const CommandControl& command_control) = 0;
419 virtual RequestPingMessage Ping(size_t shard, std::string message,
const CommandControl& command_control) = 0;
421 virtual void Publish(
428 virtual void Spublish(std::string channel, std::string message,
const CommandControl& command_control) = 0;
430 virtual RequestRename Rename(std::string key, std::string new_key,
const CommandControl& command_control) = 0;
432 virtual RequestRpop Rpop(std::string key,
const CommandControl& command_control) = 0;
434 virtual RequestRpush Rpush(std::string key, std::string value,
const CommandControl& command_control) = 0;
436 virtual RequestRpush Rpush(
438 std::vector<std::string> values,
442 virtual RequestRpushx Rpushx(std::string key, std::string element,
const CommandControl& command_control) = 0;
448 virtual RequestSadd
Sadd(std::string key, std::string member,
const CommandControl& command_control) = 0;
453 std::vector<std::string> members,
461 virtual RequestScan
Scan(size_t shard, ScanOptions options,
const CommandControl& command_control) = 0;
463 virtual RequestScard Scard(std::string key,
const CommandControl& command_control) = 0;
465 virtual RequestSet Set(std::string key, std::string value,
const CommandControl& command_control) = 0;
467 virtual RequestSet Set(
470 std::chrono::milliseconds ttl,
474 virtual RequestSetIfExist SetIfExist(std::string key, std::string value,
const CommandControl& command_control) = 0;
476 virtual RequestSetIfExist SetIfExist(
479 std::chrono::milliseconds ttl,
483 virtual RequestSetIfNotExist SetIfNotExist(
489 virtual RequestSetIfNotExist SetIfNotExist(
492 std::chrono::milliseconds ttl,
496 virtual RequestSetIfNotExistOrGet SetIfNotExistOrGet(
502 virtual RequestSetIfNotExistOrGet SetIfNotExistOrGet(
505 std::chrono::milliseconds ttl,
509 virtual RequestSetex Setex(
511 std::chrono::seconds seconds,
516 virtual RequestSetAndGetPrevious SetAndGetPrevious(
519 std::chrono::milliseconds ttl,
523 virtual RequestSismember Sismember(std::string key, std::string member,
const CommandControl& command_control) = 0;
526 virtual RequestSmembers Smembers(std::string key,
const CommandControl& command_control) = 0;
528 virtual RequestSrandmember Srandmember(std::string key,
const CommandControl& command_control) = 0;
530 virtual RequestSrandmembers Srandmembers(std::string key, int64_t count,
const CommandControl& command_control) = 0;
532 virtual RequestSrem Srem(std::string key, std::string member,
const CommandControl& command_control) = 0;
534 virtual RequestSrem Srem(
536 std::vector<std::string> members,
544 virtual RequestSscan
Sscan(std::string key, SscanOptions options,
const CommandControl& command_control) = 0;
546 virtual RequestStrlen Strlen(std::string key,
const CommandControl& command_control) = 0;
548 virtual RequestTime Time(size_t shard,
const CommandControl& command_control) = 0;
550 virtual RequestTtl Ttl(std::string key,
const CommandControl& command_control) = 0;
552 virtual RequestType Type(std::string key,
const CommandControl& command_control) = 0;
554 virtual RequestZadd Zadd(
561 virtual RequestZadd Zadd(
569 virtual RequestZadd Zadd(
571 std::vector<std::pair<
double, std::string>> scored_members,
575 virtual RequestZadd Zadd(
577 std::vector<std::pair<
double, std::string>> scored_members,
582 virtual RequestZaddIncr ZaddIncr(
589 virtual RequestZaddIncrExisting ZaddIncrExisting(
596 virtual RequestZcard Zcard(std::string key,
const CommandControl& command_control) = 0;
598 virtual RequestZcount Zcount(std::string key,
double min,
double max,
const CommandControl& command_control) = 0;
600 virtual RequestZrange Zrange(
607 virtual RequestZrangeWithScores ZrangeWithScores(
614 virtual RequestZrangebyscore Zrangebyscore(
621 virtual RequestZrangebyscore Zrangebyscore(
628 virtual RequestZrangebyscore Zrangebyscore(
636 virtual RequestZrangebyscore Zrangebyscore(
644 virtual RequestZrangebyscoreWithScores ZrangebyscoreWithScores(
651 virtual RequestZrangebyscoreWithScores ZrangebyscoreWithScores(
658 virtual RequestZrangebyscoreWithScores ZrangebyscoreWithScores(
666 virtual RequestZrangebyscoreWithScores ZrangebyscoreWithScores(
674 virtual RequestZrem Zrem(std::string key, std::string member,
const CommandControl& command_control) = 0;
676 virtual RequestZrem Zrem(
678 std::vector<std::string> members,
682 virtual RequestZremrangebyrank Zremrangebyrank(
689 virtual RequestZremrangebyscore Zremrangebyscore(
696 virtual RequestZremrangebyscore Zremrangebyscore(
707 virtual RequestZscan
Zscan(std::string key, ZscanOptions options,
const CommandControl& command_control) = 0;
709 virtual RequestZscore Zscore(std::string key, std::string member,
const CommandControl& command_control) = 0;
716 std::chrono::seconds ttl,
717 std::vector<std::string> fields,
724 std::chrono::seconds ttl,
726 std::vector<std::string> fields,
733 std::chrono::milliseconds ttl,
734 std::vector<std::string> fields,
741 std::chrono::milliseconds ttl,
743 std::vector<std::string> fields,
750 std::chrono::system_clock::time_point deadline,
751 std::vector<std::string> fields,
758 std::chrono::system_clock::time_point deadline,
760 std::vector<std::string> fields,
767 std::chrono::system_clock::time_point deadline,
768 std::vector<std::string> fields,
775 std::chrono::system_clock::time_point deadline,
777 std::vector<std::string> fields,
784 std::vector<std::string> fields,
791 std::vector<std::string> fields,
798 std::vector<std::string> fields,
805 std::vector<std::string> fields,
812 std::vector<std::string> fields,
819 std::vector<std::string> fields,
827 std::vector<std::string> fields,
881 std::vector<std::string> paths,
887 std::vector<std::string> keys,
894 std::vector<JsonKeyPathValue> key_path_values,
904 RequestZscore Zscore(
911 void Publish(std::string channel, std::string message,
const CommandControl& command_control);
913 RequestScan Scan(size_t shard,
const CommandControl& command_control);
915 RequestHscan Hscan(std::string key,
const CommandControl& command_control);
917 RequestSscan Sscan(std::string key,
const CommandControl& command_control);
919 RequestZscan Zscan(std::string key,
const CommandControl& command_control);
922 virtual RequestEvalCommon EvalCommon(
924 std::vector<std::string> keys,
925 std::vector<std::string> args,
928 virtual RequestEvalShaCommon EvalShaCommon(
929 std::string script_hash,
930 std::vector<std::string> keys,
931 std::vector<std::string> args,
934 virtual RequestEvalCommon EvalReadOnlyCommon(
936 std::vector<std::string> keys,
937 std::vector<std::string> args,
940 virtual RequestEvalShaCommon EvalShaReadOnlyCommon(
941 std::string script_hash,
942 std::vector<std::string> keys,
943 std::vector<std::string> args,
946 virtual RequestGenericCommon GenericCommon(
948 std::vector<std::string> args,