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)
157 template <
typename ReplyType>
160 std::vector<std::string> args,
164 return RequestGeneric<ReplyType>{GenericCommon(std::move(command), std::move(args), key_index, command_control)
175 template <
typename ScriptInfo,
typename ReplyType = std::decay_t<ScriptInfo>>
176 RequestEval<std::decay_t<ScriptInfo>, ReplyType>
Eval(
177 const ScriptInfo& script_info,
178 std::vector<std::string> keys,
179 std::vector<std::string> args,
182 return RequestEval<std::decay_t<ScriptInfo>, ReplyType>{
183 EvalCommon(script_info.GetScript(), std::move(keys), std::move(args), command_control)
187 virtual RequestExists Exists(std::string key,
const CommandControl& command_control) = 0;
189 virtual RequestExists Exists(std::vector<std::string> keys,
const CommandControl& command_control) = 0;
191 virtual RequestExpire Expire(std::string key, std::chrono::seconds ttl,
const CommandControl& command_control) = 0;
193 virtual RequestExpire Expire(
195 std::chrono::seconds ttl,
200 virtual RequestGeoadd Geoadd(std::string key,
GeoaddArg point_member,
const CommandControl& command_control) = 0;
202 virtual RequestGeoadd Geoadd(
208 virtual RequestGeopos Geopos(
210 std::vector<std::string> members,
214 virtual RequestGeoradius Georadius(
223 virtual RequestGeosearch Geosearch(
231 virtual RequestGeosearch Geosearch(
240 virtual RequestGeosearch Geosearch(
249 virtual RequestGeosearch Geosearch(
259 virtual RequestGet Get(std::string key,
const CommandControl& command_control) = 0;
261 virtual RequestGetset Getset(std::string key, std::string value,
const CommandControl& command_control) = 0;
263 virtual RequestHdel Hdel(std::string key, std::string field,
const CommandControl& command_control) = 0;
265 virtual RequestHdel Hdel(
267 std::vector<std::string> fields,
271 virtual RequestHexists Hexists(std::string key, std::string field,
const CommandControl& command_control) = 0;
273 virtual RequestHget Hget(std::string key, std::string field,
const CommandControl& command_control) = 0;
276 virtual RequestHgetall Hgetall(std::string key,
const CommandControl& command_control) = 0;
278 virtual RequestHincrby Hincrby(
285 virtual RequestHincrbyfloat Hincrbyfloat(
293 virtual RequestHkeys Hkeys(std::string key,
const CommandControl& command_control) = 0;
295 virtual RequestHlen Hlen(std::string key,
const CommandControl& command_control) = 0;
297 virtual RequestHmget Hmget(
299 std::vector<std::string> fields,
303 virtual RequestHmset Hmset(
305 std::vector<std::pair<std::string, std::string>> field_values,
313 virtual RequestHscan
Hscan(std::string key, HscanOptions options,
const CommandControl& command_control) = 0;
315 virtual RequestHset Hset(
322 virtual RequestHsetnx Hsetnx(
330 virtual RequestHvals Hvals(std::string key,
const CommandControl& command_control) = 0;
332 virtual RequestIncr Incr(std::string key,
const CommandControl& command_control) = 0;
334 [[
deprecated(
"use Scan")]]
virtual RequestKeys Keys(
335 std::string keys_pattern,
340 virtual RequestLindex Lindex(std::string key, int64_t index,
const CommandControl& command_control) = 0;
342 virtual RequestLlen Llen(std::string key,
const CommandControl& command_control) = 0;
344 virtual RequestLpop Lpop(std::string key,
const CommandControl& command_control) = 0;
346 virtual RequestLpush Lpush(std::string key, std::string value,
const CommandControl& command_control) = 0;
348 virtual RequestLpush Lpush(
350 std::vector<std::string> values,
354 virtual RequestLpushx Lpushx(std::string key, std::string element,
const CommandControl& command_control) = 0;
356 virtual RequestLrange Lrange(
363 virtual RequestLrem Lrem(
370 virtual RequestLtrim Ltrim(std::string key, int64_t start, int64_t stop,
const CommandControl& command_control) = 0;
372 virtual RequestMget Mget(std::vector<std::string> keys,
const CommandControl& command_control) = 0;
374 virtual RequestMset Mset(
375 std::vector<std::pair<std::string, std::string>> key_values,
379 virtual TransactionPtr Multi() = 0;
381 virtual TransactionPtr Multi(
Transaction::CheckShards check_shards) = 0;
383 virtual RequestPersist Persist(std::string key,
const CommandControl& command_control) = 0;
385 virtual RequestPexpire Pexpire(
387 std::chrono::milliseconds ttl,
391 virtual RequestPing Ping(size_t shard,
const CommandControl& command_control) = 0;
393 virtual RequestPingMessage Ping(size_t shard, std::string message,
const CommandControl& command_control) = 0;
395 virtual void Publish(
402 virtual void Spublish(std::string channel, std::string message,
const CommandControl& command_control) = 0;
404 virtual RequestRename Rename(std::string key, std::string new_key,
const CommandControl& command_control) = 0;
406 virtual RequestRpop Rpop(std::string key,
const CommandControl& command_control) = 0;
408 virtual RequestRpush Rpush(std::string key, std::string value,
const CommandControl& command_control) = 0;
410 virtual RequestRpush Rpush(
412 std::vector<std::string> values,
416 virtual RequestRpushx Rpushx(std::string key, std::string element,
const CommandControl& command_control) = 0;
422 virtual RequestSadd
Sadd(std::string key, std::string member,
const CommandControl& command_control) = 0;
427 std::vector<std::string> members,
435 virtual RequestScan
Scan(size_t shard, ScanOptions options,
const CommandControl& command_control) = 0;
437 virtual RequestScard Scard(std::string key,
const CommandControl& command_control) = 0;
439 virtual RequestSet Set(std::string key, std::string value,
const CommandControl& command_control) = 0;
441 virtual RequestSet Set(
444 std::chrono::milliseconds ttl,
448 virtual RequestSetIfExist SetIfExist(std::string key, std::string value,
const CommandControl& command_control) = 0;
450 virtual RequestSetIfExist SetIfExist(
453 std::chrono::milliseconds ttl,
457 virtual RequestSetIfNotExist SetIfNotExist(
463 virtual RequestSetIfNotExist SetIfNotExist(
466 std::chrono::milliseconds ttl,
470 virtual RequestSetIfNotExistOrGet SetIfNotExistOrGet(
476 virtual RequestSetIfNotExistOrGet SetIfNotExistOrGet(
479 std::chrono::milliseconds ttl,
483 virtual RequestSetex Setex(
485 std::chrono::seconds seconds,
490 virtual RequestSetAndGetPrevious SetAndGetPrevious(
493 std::chrono::milliseconds ttl,
497 virtual RequestSismember Sismember(std::string key, std::string member,
const CommandControl& command_control) = 0;
500 virtual RequestSmembers Smembers(std::string key,
const CommandControl& command_control) = 0;
502 virtual RequestSrandmember Srandmember(std::string key,
const CommandControl& command_control) = 0;
504 virtual RequestSrandmembers Srandmembers(std::string key, int64_t count,
const CommandControl& command_control) = 0;
506 virtual RequestSrem Srem(std::string key, std::string member,
const CommandControl& command_control) = 0;
508 virtual RequestSrem Srem(
510 std::vector<std::string> members,
518 virtual RequestSscan
Sscan(std::string key, SscanOptions options,
const CommandControl& command_control) = 0;
520 virtual RequestStrlen Strlen(std::string key,
const CommandControl& command_control) = 0;
522 virtual RequestTime Time(size_t shard,
const CommandControl& command_control) = 0;
524 virtual RequestTtl Ttl(std::string key,
const CommandControl& command_control) = 0;
526 virtual RequestType Type(std::string key,
const CommandControl& command_control) = 0;
528 virtual RequestZadd Zadd(
535 virtual RequestZadd Zadd(
543 virtual RequestZadd Zadd(
545 std::vector<std::pair<
double, std::string>> scored_members,
549 virtual RequestZadd Zadd(
551 std::vector<std::pair<
double, std::string>> scored_members,
556 virtual RequestZaddIncr ZaddIncr(
563 virtual RequestZaddIncrExisting ZaddIncrExisting(
570 virtual RequestZcard Zcard(std::string key,
const CommandControl& command_control) = 0;
572 virtual RequestZcount Zcount(std::string key,
double min,
double max,
const CommandControl& command_control) = 0;
574 virtual RequestZrange Zrange(
581 virtual RequestZrangeWithScores ZrangeWithScores(
588 virtual RequestZrangebyscore Zrangebyscore(
595 virtual RequestZrangebyscore Zrangebyscore(
602 virtual RequestZrangebyscore Zrangebyscore(
610 virtual RequestZrangebyscore Zrangebyscore(
618 virtual RequestZrangebyscoreWithScores ZrangebyscoreWithScores(
625 virtual RequestZrangebyscoreWithScores ZrangebyscoreWithScores(
632 virtual RequestZrangebyscoreWithScores ZrangebyscoreWithScores(
640 virtual RequestZrangebyscoreWithScores ZrangebyscoreWithScores(
648 virtual RequestZrem Zrem(std::string key, std::string member,
const CommandControl& command_control) = 0;
650 virtual RequestZrem Zrem(
652 std::vector<std::string> members,
656 virtual RequestZremrangebyrank Zremrangebyrank(
663 virtual RequestZremrangebyscore Zremrangebyscore(
670 virtual RequestZremrangebyscore Zremrangebyscore(
681 virtual RequestZscan
Zscan(std::string key, ZscanOptions options,
const CommandControl& command_control) = 0;
683 virtual RequestZscore Zscore(std::string key, std::string member,
const CommandControl& command_control) = 0;
690 std::chrono::seconds ttl,
691 std::vector<std::string> fields,
698 std::chrono::seconds ttl,
700 std::vector<std::string> fields,
707 std::chrono::milliseconds ttl,
708 std::vector<std::string> fields,
715 std::chrono::milliseconds ttl,
717 std::vector<std::string> fields,
724 std::chrono::system_clock::time_point deadline,
725 std::vector<std::string> fields,
732 std::chrono::system_clock::time_point deadline,
734 std::vector<std::string> fields,
741 std::chrono::system_clock::time_point deadline,
742 std::vector<std::string> fields,
749 std::chrono::system_clock::time_point deadline,
751 std::vector<std::string> fields,
758 std::vector<std::string> fields,
765 std::vector<std::string> fields,
772 std::vector<std::string> fields,
779 std::vector<std::string> fields,
786 std::vector<std::string> fields,
793 std::vector<std::string> fields,
801 std::vector<std::string> fields,
855 std::vector<std::string> paths,
861 std::vector<std::string> keys,
868 std::vector<JsonKeyPathValue> key_path_values,
878 RequestZscore Zscore(
885 void Publish(std::string channel, std::string message,
const CommandControl& command_control);
887 RequestScan Scan(size_t shard,
const CommandControl& command_control);
889 RequestHscan Hscan(std::string key,
const CommandControl& command_control);
891 RequestSscan Sscan(std::string key,
const CommandControl& command_control);
893 RequestZscan Zscan(std::string key,
const CommandControl& command_control);
896 virtual RequestEvalCommon EvalCommon(
898 std::vector<std::string> keys,
899 std::vector<std::string> args,
902 virtual RequestEvalShaCommon EvalShaCommon(
903 std::string script_hash,
904 std::vector<std::string> keys,
905 std::vector<std::string> args,
908 virtual RequestEvalCommon EvalReadOnlyCommon(
910 std::vector<std::string> keys,
911 std::vector<std::string> args,
914 virtual RequestEvalShaCommon EvalShaReadOnlyCommon(
915 std::string script_hash,
916 std::vector<std::string> keys,
917 std::vector<std::string> args,
920 virtual RequestGenericCommon GenericCommon(
922 std::vector<std::string> args,