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;
55 virtual RequestAppend Append(std::string key, std::string value,
const CommandControl& command_control) = 0;
57 virtual RequestBitop Bitop(
60 std::vector<std::string> src_keys,
64 virtual RequestDbsize Dbsize(size_t shard,
const CommandControl& command_control) = 0;
66 virtual RequestDecr Decr(std::string key,
const CommandControl& command_control) = 0;
68 virtual RequestDel Del(std::string key,
const CommandControl& command_control) = 0;
70 virtual RequestDel Del(std::vector<std::string> keys,
const CommandControl& command_control) = 0;
72 virtual RequestUnlink Unlink(std::string key,
const CommandControl& command_control) = 0;
74 virtual RequestUnlink Unlink(std::vector<std::string> keys,
const CommandControl& command_control) = 0;
82 template <
typename ScriptResult,
typename ReplyType = ScriptResult>
83 RequestEval<ScriptResult, ReplyType>
Eval(
85 std::vector<std::string> keys,
86 std::vector<std::string> args,
89 return RequestEval<ScriptResult, ReplyType>{
90 EvalCommon(std::move(script), std::move(keys), std::move(args), command_control)
101 template <
typename ScriptResult,
typename ReplyType = ScriptResult>
102 RequestEvalSha<ScriptResult, ReplyType>
EvalSha(
103 std::string script_hash,
104 std::vector<std::string> keys,
105 std::vector<std::string> args,
108 return RequestEvalSha<ScriptResult, ReplyType>{
109 EvalShaCommon(std::move(script_hash), std::move(keys), std::move(args), command_control)
119 template <
typename ScriptResult,
typename ReplyType = ScriptResult>
122 std::vector<std::string> keys,
123 std::vector<std::string> args,
126 return RequestEval<ScriptResult, ReplyType>{
127 EvalReadOnlyCommon(std::move(script), std::move(keys), std::move(args), command_control)
137 template <
typename ScriptResult,
typename ReplyType = ScriptResult>
139 std::string script_hash,
140 std::vector<std::string> keys,
141 std::vector<std::string> args,
144 return RequestEvalSha<ScriptResult, ReplyType>{
145 EvalShaReadOnlyCommon(std::move(script_hash), std::move(keys), std::move(args), command_control)
154 template <
typename ReplyType>
157 std::vector<std::string> args,
161 return RequestGeneric<ReplyType>{GenericCommon(std::move(command), std::move(args), key_index, command_control)
172 template <
typename ScriptInfo,
typename ReplyType = std::decay_t<ScriptInfo>>
173 RequestEval<std::decay_t<ScriptInfo>, ReplyType>
Eval(
174 const ScriptInfo& script_info,
175 std::vector<std::string> keys,
176 std::vector<std::string> args,
179 return RequestEval<std::decay_t<ScriptInfo>, ReplyType>{
180 EvalCommon(script_info.GetScript(), std::move(keys), std::move(args), command_control)
184 virtual RequestExists Exists(std::string key,
const CommandControl& command_control) = 0;
186 virtual RequestExists Exists(std::vector<std::string> keys,
const CommandControl& command_control) = 0;
188 virtual RequestExpire Expire(std::string key, std::chrono::seconds ttl,
const CommandControl& command_control) = 0;
190 virtual RequestExpire Expire(
192 std::chrono::seconds ttl,
197 virtual RequestGeoadd Geoadd(std::string key,
GeoaddArg point_member,
const CommandControl& command_control) = 0;
199 virtual RequestGeoadd Geoadd(
205 virtual RequestGeopos Geopos(
207 std::vector<std::string> members,
211 virtual RequestGeoradius Georadius(
220 virtual RequestGeosearch Geosearch(
228 virtual RequestGeosearch Geosearch(
237 virtual RequestGeosearch Geosearch(
246 virtual RequestGeosearch Geosearch(
256 virtual RequestGet Get(std::string key,
const CommandControl& command_control) = 0;
258 virtual RequestGetset Getset(std::string key, std::string value,
const CommandControl& command_control) = 0;
260 virtual RequestHdel Hdel(std::string key, std::string field,
const CommandControl& command_control) = 0;
262 virtual RequestHdel Hdel(
264 std::vector<std::string> fields,
268 virtual RequestHexists Hexists(std::string key, std::string field,
const CommandControl& command_control) = 0;
270 virtual RequestHget Hget(std::string key, std::string field,
const CommandControl& command_control) = 0;
273 virtual RequestHgetall Hgetall(std::string key,
const CommandControl& command_control) = 0;
275 virtual RequestHincrby Hincrby(
282 virtual RequestHincrbyfloat Hincrbyfloat(
290 virtual RequestHkeys Hkeys(std::string key,
const CommandControl& command_control) = 0;
292 virtual RequestHlen Hlen(std::string key,
const CommandControl& command_control) = 0;
294 virtual RequestHmget Hmget(
296 std::vector<std::string> fields,
300 virtual RequestHmset Hmset(
302 std::vector<std::pair<std::string, std::string>> field_values,
310 virtual RequestHscan
Hscan(std::string key, HscanOptions options,
const CommandControl& command_control) = 0;
312 virtual RequestHset Hset(
319 virtual RequestHsetnx Hsetnx(
327 virtual RequestHvals Hvals(std::string key,
const CommandControl& command_control) = 0;
329 virtual RequestIncr Incr(std::string key,
const CommandControl& command_control) = 0;
331 [[
deprecated(
"use Scan")]]
virtual RequestKeys Keys(
332 std::string keys_pattern,
337 virtual RequestLindex Lindex(std::string key, int64_t index,
const CommandControl& command_control) = 0;
339 virtual RequestLlen Llen(std::string key,
const CommandControl& command_control) = 0;
341 virtual RequestLpop Lpop(std::string key,
const CommandControl& command_control) = 0;
343 virtual RequestLpush Lpush(std::string key, std::string value,
const CommandControl& command_control) = 0;
345 virtual RequestLpush Lpush(
347 std::vector<std::string> values,
351 virtual RequestLpushx Lpushx(std::string key, std::string element,
const CommandControl& command_control) = 0;
353 virtual RequestLrange Lrange(
360 virtual RequestLrem Lrem(
367 virtual RequestLtrim Ltrim(std::string key, int64_t start, int64_t stop,
const CommandControl& command_control) = 0;
369 virtual RequestMget Mget(std::vector<std::string> keys,
const CommandControl& command_control) = 0;
371 virtual RequestMset Mset(
372 std::vector<std::pair<std::string, std::string>> key_values,
376 virtual TransactionPtr Multi() = 0;
378 virtual TransactionPtr Multi(
Transaction::CheckShards check_shards) = 0;
380 virtual RequestPersist Persist(std::string key,
const CommandControl& command_control) = 0;
382 virtual RequestPexpire Pexpire(
384 std::chrono::milliseconds ttl,
388 virtual RequestPing Ping(size_t shard,
const CommandControl& command_control) = 0;
390 virtual RequestPingMessage Ping(size_t shard, std::string message,
const CommandControl& command_control) = 0;
392 virtual void Publish(
399 virtual void Spublish(std::string channel, std::string message,
const CommandControl& command_control) = 0;
401 virtual RequestRename Rename(std::string key, std::string new_key,
const CommandControl& command_control) = 0;
403 virtual RequestRpop Rpop(std::string key,
const CommandControl& command_control) = 0;
405 virtual RequestRpush Rpush(std::string key, std::string value,
const CommandControl& command_control) = 0;
407 virtual RequestRpush Rpush(
409 std::vector<std::string> values,
413 virtual RequestRpushx Rpushx(std::string key, std::string element,
const CommandControl& command_control) = 0;
419 virtual RequestSadd
Sadd(std::string key, std::string member,
const CommandControl& command_control) = 0;
424 std::vector<std::string> members,
432 virtual RequestScan
Scan(size_t shard, ScanOptions options,
const CommandControl& command_control) = 0;
434 virtual RequestScard Scard(std::string key,
const CommandControl& command_control) = 0;
436 virtual RequestSet Set(std::string key, std::string value,
const CommandControl& command_control) = 0;
438 virtual RequestSet Set(
441 std::chrono::milliseconds ttl,
445 virtual RequestSetIfExist SetIfExist(std::string key, std::string value,
const CommandControl& command_control) = 0;
447 virtual RequestSetIfExist SetIfExist(
450 std::chrono::milliseconds ttl,
454 virtual RequestSetIfNotExist SetIfNotExist(
460 virtual RequestSetIfNotExist SetIfNotExist(
463 std::chrono::milliseconds ttl,
467 virtual RequestSetIfNotExistOrGet SetIfNotExistOrGet(
473 virtual RequestSetIfNotExistOrGet SetIfNotExistOrGet(
476 std::chrono::milliseconds ttl,
480 virtual RequestSetex Setex(
482 std::chrono::seconds seconds,
487 virtual RequestSismember Sismember(std::string key, std::string member,
const CommandControl& command_control) = 0;
490 virtual RequestSmembers Smembers(std::string key,
const CommandControl& command_control) = 0;
492 virtual RequestSrandmember Srandmember(std::string key,
const CommandControl& command_control) = 0;
494 virtual RequestSrandmembers Srandmembers(std::string key, int64_t count,
const CommandControl& command_control) = 0;
496 virtual RequestSrem Srem(std::string key, std::string member,
const CommandControl& command_control) = 0;
498 virtual RequestSrem Srem(
500 std::vector<std::string> members,
508 virtual RequestSscan
Sscan(std::string key, SscanOptions options,
const CommandControl& command_control) = 0;
510 virtual RequestStrlen Strlen(std::string key,
const CommandControl& command_control) = 0;
512 virtual RequestTime Time(size_t shard,
const CommandControl& command_control) = 0;
514 virtual RequestTtl Ttl(std::string key,
const CommandControl& command_control) = 0;
516 virtual RequestType Type(std::string key,
const CommandControl& command_control) = 0;
518 virtual RequestZadd Zadd(
525 virtual RequestZadd Zadd(
533 virtual RequestZadd Zadd(
535 std::vector<std::pair<
double, std::string>> scored_members,
539 virtual RequestZadd Zadd(
541 std::vector<std::pair<
double, std::string>> scored_members,
546 virtual RequestZaddIncr ZaddIncr(
553 virtual RequestZaddIncrExisting ZaddIncrExisting(
560 virtual RequestZcard Zcard(std::string key,
const CommandControl& command_control) = 0;
562 virtual RequestZcount Zcount(std::string key,
double min,
double max,
const CommandControl& command_control) = 0;
564 virtual RequestZrange Zrange(
571 virtual RequestZrangeWithScores ZrangeWithScores(
578 virtual RequestZrangebyscore Zrangebyscore(
585 virtual RequestZrangebyscore Zrangebyscore(
592 virtual RequestZrangebyscore Zrangebyscore(
600 virtual RequestZrangebyscore Zrangebyscore(
608 virtual RequestZrangebyscoreWithScores ZrangebyscoreWithScores(
615 virtual RequestZrangebyscoreWithScores ZrangebyscoreWithScores(
622 virtual RequestZrangebyscoreWithScores ZrangebyscoreWithScores(
630 virtual RequestZrangebyscoreWithScores ZrangebyscoreWithScores(
638 virtual RequestZrem Zrem(std::string key, std::string member,
const CommandControl& command_control) = 0;
640 virtual RequestZrem Zrem(
642 std::vector<std::string> members,
646 virtual RequestZremrangebyrank Zremrangebyrank(
653 virtual RequestZremrangebyscore Zremrangebyscore(
660 virtual RequestZremrangebyscore Zremrangebyscore(
671 virtual RequestZscan
Zscan(std::string key, ZscanOptions options,
const CommandControl& command_control) = 0;
673 virtual RequestZscore Zscore(std::string key, std::string member,
const CommandControl& command_control) = 0;
681 RequestZscore Zscore(
688 void Publish(std::string channel, std::string message,
const CommandControl& command_control);
690 RequestScan Scan(size_t shard,
const CommandControl& command_control);
692 RequestHscan Hscan(std::string key,
const CommandControl& command_control);
694 RequestSscan Sscan(std::string key,
const CommandControl& command_control);
696 RequestZscan Zscan(std::string key,
const CommandControl& command_control);
699 virtual RequestEvalCommon EvalCommon(
701 std::vector<std::string> keys,
702 std::vector<std::string> args,
705 virtual RequestEvalShaCommon EvalShaCommon(
706 std::string script_hash,
707 std::vector<std::string> keys,
708 std::vector<std::string> args,
711 virtual RequestEvalCommon EvalReadOnlyCommon(
713 std::vector<std::string> keys,
714 std::vector<std::string> args,
717 virtual RequestEvalShaCommon EvalShaReadOnlyCommon(
718 std::string script_hash,
719 std::vector<std::string> keys,
720 std::vector<std::string> args,
723 virtual RequestGenericCommon GenericCommon(
725 std::vector<std::string> args,