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 RequestGetdel Getdel(std::string key,
const CommandControl& command_control) = 0;
263 virtual RequestGetset Getset(std::string key, std::string value,
const CommandControl& command_control) = 0;
265 virtual RequestHdel Hdel(std::string key, std::string field,
const CommandControl& command_control) = 0;
267 virtual RequestHdel Hdel(
269 std::vector<std::string> fields,
273 virtual RequestHexists Hexists(std::string key, std::string field,
const CommandControl& command_control) = 0;
275 virtual RequestHget Hget(std::string key, std::string field,
const CommandControl& command_control) = 0;
278 virtual RequestHgetall Hgetall(std::string key,
const CommandControl& command_control) = 0;
280 virtual RequestHincrby Hincrby(
287 virtual RequestHincrbyfloat Hincrbyfloat(
295 virtual RequestHkeys Hkeys(std::string key,
const CommandControl& command_control) = 0;
297 virtual RequestHlen Hlen(std::string key,
const CommandControl& command_control) = 0;
299 virtual RequestHmget Hmget(
301 std::vector<std::string> fields,
305 virtual RequestHmset Hmset(
307 std::vector<std::pair<std::string, std::string>> field_values,
315 virtual RequestHscan
Hscan(std::string key, HscanOptions options,
const CommandControl& command_control) = 0;
317 virtual RequestHset Hset(
324 virtual RequestHsetnx Hsetnx(
332 virtual RequestHvals Hvals(std::string key,
const CommandControl& command_control) = 0;
334 virtual RequestIncr Incr(std::string key,
const CommandControl& command_control) = 0;
336 [[
deprecated(
"use Scan")]]
virtual RequestKeys Keys(
337 std::string keys_pattern,
342 virtual RequestLindex Lindex(std::string key, int64_t index,
const CommandControl& command_control) = 0;
344 virtual RequestLlen Llen(std::string key,
const CommandControl& command_control) = 0;
346 virtual RequestLpop Lpop(std::string key,
const CommandControl& command_control) = 0;
348 virtual RequestLpush Lpush(std::string key, std::string value,
const CommandControl& command_control) = 0;
350 virtual RequestLpush Lpush(
352 std::vector<std::string> values,
356 virtual RequestLpushx Lpushx(std::string key, std::string element,
const CommandControl& command_control) = 0;
358 virtual RequestLrange Lrange(
365 virtual RequestLrem Lrem(
372 virtual RequestLtrim Ltrim(std::string key, int64_t start, int64_t stop,
const CommandControl& command_control) = 0;
374 virtual RequestMget Mget(std::vector<std::string> keys,
const CommandControl& command_control) = 0;
376 virtual RequestMset Mset(
377 std::vector<std::pair<std::string, std::string>> key_values,
381 virtual TransactionPtr Multi() = 0;
383 virtual TransactionPtr Multi(
Transaction::CheckShards check_shards) = 0;
385 virtual RequestPersist Persist(std::string key,
const CommandControl& command_control) = 0;
387 virtual RequestPexpire Pexpire(
389 std::chrono::milliseconds ttl,
393 virtual RequestPing Ping(size_t shard,
const CommandControl& command_control) = 0;
395 virtual RequestPingMessage Ping(size_t shard, std::string message,
const CommandControl& command_control) = 0;
397 virtual void Publish(
404 virtual void Spublish(std::string channel, std::string message,
const CommandControl& command_control) = 0;
406 virtual RequestRename Rename(std::string key, std::string new_key,
const CommandControl& command_control) = 0;
408 virtual RequestRpop Rpop(std::string key,
const CommandControl& command_control) = 0;
410 virtual RequestRpush Rpush(std::string key, std::string value,
const CommandControl& command_control) = 0;
412 virtual RequestRpush Rpush(
414 std::vector<std::string> values,
418 virtual RequestRpushx Rpushx(std::string key, std::string element,
const CommandControl& command_control) = 0;
424 virtual RequestSadd
Sadd(std::string key, std::string member,
const CommandControl& command_control) = 0;
429 std::vector<std::string> members,
437 virtual RequestScan
Scan(size_t shard, ScanOptions options,
const CommandControl& command_control) = 0;
439 virtual RequestScard Scard(std::string key,
const CommandControl& command_control) = 0;
441 virtual RequestSet Set(std::string key, std::string value,
const CommandControl& command_control) = 0;
443 virtual RequestSet Set(
446 std::chrono::milliseconds ttl,
450 virtual RequestSetIfExist SetIfExist(std::string key, std::string value,
const CommandControl& command_control) = 0;
452 virtual RequestSetIfExist SetIfExist(
455 std::chrono::milliseconds ttl,
459 virtual RequestSetIfNotExist SetIfNotExist(
465 virtual RequestSetIfNotExist SetIfNotExist(
468 std::chrono::milliseconds ttl,
472 virtual RequestSetIfNotExistOrGet SetIfNotExistOrGet(
478 virtual RequestSetIfNotExistOrGet SetIfNotExistOrGet(
481 std::chrono::milliseconds ttl,
485 virtual RequestSetex Setex(
487 std::chrono::seconds seconds,
492 virtual RequestSetAndGetPrevious SetAndGetPrevious(
495 std::chrono::milliseconds ttl,
499 virtual RequestSismember Sismember(std::string key, std::string member,
const CommandControl& command_control) = 0;
502 virtual RequestSmembers Smembers(std::string key,
const CommandControl& command_control) = 0;
504 virtual RequestSrandmember Srandmember(std::string key,
const CommandControl& command_control) = 0;
506 virtual RequestSrandmembers Srandmembers(std::string key, int64_t count,
const CommandControl& command_control) = 0;
508 virtual RequestSrem Srem(std::string key, std::string member,
const CommandControl& command_control) = 0;
510 virtual RequestSrem Srem(
512 std::vector<std::string> members,
520 virtual RequestSscan
Sscan(std::string key, SscanOptions options,
const CommandControl& command_control) = 0;
522 virtual RequestStrlen Strlen(std::string key,
const CommandControl& command_control) = 0;
524 virtual RequestTime Time(size_t shard,
const CommandControl& command_control) = 0;
526 virtual RequestTtl Ttl(std::string key,
const CommandControl& command_control) = 0;
528 virtual RequestType Type(std::string key,
const CommandControl& command_control) = 0;
530 virtual RequestZadd Zadd(
537 virtual RequestZadd Zadd(
545 virtual RequestZadd Zadd(
547 std::vector<std::pair<
double, std::string>> scored_members,
551 virtual RequestZadd Zadd(
553 std::vector<std::pair<
double, std::string>> scored_members,
558 virtual RequestZaddIncr ZaddIncr(
565 virtual RequestZaddIncrExisting ZaddIncrExisting(
572 virtual RequestZcard Zcard(std::string key,
const CommandControl& command_control) = 0;
574 virtual RequestZcount Zcount(std::string key,
double min,
double max,
const CommandControl& command_control) = 0;
576 virtual RequestZrange Zrange(
583 virtual RequestZrangeWithScores ZrangeWithScores(
590 virtual RequestZrangebyscore Zrangebyscore(
597 virtual RequestZrangebyscore Zrangebyscore(
604 virtual RequestZrangebyscore Zrangebyscore(
612 virtual RequestZrangebyscore Zrangebyscore(
620 virtual RequestZrangebyscoreWithScores ZrangebyscoreWithScores(
627 virtual RequestZrangebyscoreWithScores ZrangebyscoreWithScores(
634 virtual RequestZrangebyscoreWithScores ZrangebyscoreWithScores(
642 virtual RequestZrangebyscoreWithScores ZrangebyscoreWithScores(
650 virtual RequestZrem Zrem(std::string key, std::string member,
const CommandControl& command_control) = 0;
652 virtual RequestZrem Zrem(
654 std::vector<std::string> members,
658 virtual RequestZremrangebyrank Zremrangebyrank(
665 virtual RequestZremrangebyscore Zremrangebyscore(
672 virtual RequestZremrangebyscore Zremrangebyscore(
683 virtual RequestZscan
Zscan(std::string key, ZscanOptions options,
const CommandControl& command_control) = 0;
685 virtual RequestZscore Zscore(std::string key, std::string member,
const CommandControl& command_control) = 0;
692 std::chrono::seconds ttl,
693 std::vector<std::string> fields,
700 std::chrono::seconds ttl,
702 std::vector<std::string> fields,
709 std::chrono::milliseconds ttl,
710 std::vector<std::string> fields,
717 std::chrono::milliseconds ttl,
719 std::vector<std::string> fields,
726 std::chrono::system_clock::time_point deadline,
727 std::vector<std::string> fields,
734 std::chrono::system_clock::time_point deadline,
736 std::vector<std::string> fields,
743 std::chrono::system_clock::time_point deadline,
744 std::vector<std::string> fields,
751 std::chrono::system_clock::time_point deadline,
753 std::vector<std::string> fields,
760 std::vector<std::string> fields,
767 std::vector<std::string> fields,
774 std::vector<std::string> fields,
781 std::vector<std::string> fields,
788 std::vector<std::string> fields,
795 std::vector<std::string> fields,
803 std::vector<std::string> fields,
857 std::vector<std::string> paths,
863 std::vector<std::string> keys,
870 std::vector<JsonKeyPathValue> key_path_values,
880 RequestZscore Zscore(
887 void Publish(std::string channel, std::string message,
const CommandControl& command_control);
889 RequestScan Scan(size_t shard,
const CommandControl& command_control);
891 RequestHscan Hscan(std::string key,
const CommandControl& command_control);
893 RequestSscan Sscan(std::string key,
const CommandControl& command_control);
895 RequestZscan Zscan(std::string key,
const CommandControl& command_control);
898 virtual RequestEvalCommon EvalCommon(
900 std::vector<std::string> keys,
901 std::vector<std::string> args,
904 virtual RequestEvalShaCommon EvalShaCommon(
905 std::string script_hash,
906 std::vector<std::string> keys,
907 std::vector<std::string> args,
910 virtual RequestEvalCommon EvalReadOnlyCommon(
912 std::vector<std::string> keys,
913 std::vector<std::string> args,
916 virtual RequestEvalShaCommon EvalShaReadOnlyCommon(
917 std::string script_hash,
918 std::vector<std::string> keys,
919 std::vector<std::string> args,
922 virtual RequestGenericCommon GenericCommon(
924 std::vector<std::string> args,