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)
118 template <
typename ReplyType>
121 std::vector<std::string> args,
125 return RequestGeneric<ReplyType>{GenericCommon(std::move(command), std::move(args), key_index, command_control)
136 template <
typename ScriptInfo,
typename ReplyType = std::decay_t<ScriptInfo>>
137 RequestEval<std::decay_t<ScriptInfo>, ReplyType>
Eval(
138 const ScriptInfo& script_info,
139 std::vector<std::string> keys,
140 std::vector<std::string> args,
143 return RequestEval<std::decay_t<ScriptInfo>, ReplyType>{
144 EvalCommon(script_info.GetScript(), std::move(keys), std::move(args), command_control)
148 virtual RequestExists Exists(std::string key,
const CommandControl& command_control) = 0;
150 virtual RequestExists Exists(std::vector<std::string> keys,
const CommandControl& command_control) = 0;
152 virtual RequestExpire Expire(std::string key, std::chrono::seconds ttl,
const CommandControl& command_control) = 0;
154 virtual RequestExpire Expire(
156 std::chrono::seconds ttl,
161 virtual RequestGeoadd Geoadd(std::string key,
GeoaddArg point_member,
const CommandControl& command_control) = 0;
163 virtual RequestGeoadd Geoadd(
169 virtual RequestGeopos Geopos(
171 std::vector<std::string> members,
175 virtual RequestGeoradius Georadius(
184 virtual RequestGeosearch Geosearch(
192 virtual RequestGeosearch Geosearch(
201 virtual RequestGeosearch Geosearch(
210 virtual RequestGeosearch Geosearch(
220 virtual RequestGet Get(std::string key,
const CommandControl& command_control) = 0;
222 virtual RequestGetset Getset(std::string key, std::string value,
const CommandControl& command_control) = 0;
224 virtual RequestHdel Hdel(std::string key, std::string field,
const CommandControl& command_control) = 0;
226 virtual RequestHdel Hdel(
228 std::vector<std::string> fields,
232 virtual RequestHexists Hexists(std::string key, std::string field,
const CommandControl& command_control) = 0;
234 virtual RequestHget Hget(std::string key, std::string field,
const CommandControl& command_control) = 0;
237 virtual RequestHgetall Hgetall(std::string key,
const CommandControl& command_control) = 0;
239 virtual RequestHincrby Hincrby(
246 virtual RequestHincrbyfloat Hincrbyfloat(
254 virtual RequestHkeys Hkeys(std::string key,
const CommandControl& command_control) = 0;
256 virtual RequestHlen Hlen(std::string key,
const CommandControl& command_control) = 0;
258 virtual RequestHmget Hmget(
260 std::vector<std::string> fields,
264 virtual RequestHmset Hmset(
266 std::vector<std::pair<std::string, std::string>> field_values,
274 virtual RequestHscan
Hscan(std::string key, HscanOptions options,
const CommandControl& command_control) = 0;
276 virtual RequestHset Hset(
283 virtual RequestHsetnx Hsetnx(
291 virtual RequestHvals Hvals(std::string key,
const CommandControl& command_control) = 0;
293 virtual RequestIncr Incr(std::string key,
const CommandControl& command_control) = 0;
295 [[
deprecated(
"use Scan")]]
virtual RequestKeys Keys(
296 std::string keys_pattern,
301 virtual RequestLindex Lindex(std::string key, int64_t index,
const CommandControl& command_control) = 0;
303 virtual RequestLlen Llen(std::string key,
const CommandControl& command_control) = 0;
305 virtual RequestLpop Lpop(std::string key,
const CommandControl& command_control) = 0;
307 virtual RequestLpush Lpush(std::string key, std::string value,
const CommandControl& command_control) = 0;
309 virtual RequestLpush Lpush(
311 std::vector<std::string> values,
315 virtual RequestLpushx Lpushx(std::string key, std::string element,
const CommandControl& command_control) = 0;
317 virtual RequestLrange Lrange(
324 virtual RequestLrem Lrem(
331 virtual RequestLtrim Ltrim(std::string key, int64_t start, int64_t stop,
const CommandControl& command_control) = 0;
333 virtual RequestMget Mget(std::vector<std::string> keys,
const CommandControl& command_control) = 0;
335 virtual RequestMset Mset(
336 std::vector<std::pair<std::string, std::string>> key_values,
340 virtual TransactionPtr Multi() = 0;
342 virtual TransactionPtr Multi(
Transaction::CheckShards check_shards) = 0;
344 virtual RequestPersist Persist(std::string key,
const CommandControl& command_control) = 0;
346 virtual RequestPexpire Pexpire(
348 std::chrono::milliseconds ttl,
352 virtual RequestPing Ping(size_t shard,
const CommandControl& command_control) = 0;
354 virtual RequestPingMessage Ping(size_t shard, std::string message,
const CommandControl& command_control) = 0;
356 virtual void Publish(
363 virtual void Spublish(std::string channel, std::string message,
const CommandControl& command_control) = 0;
365 virtual RequestRename Rename(std::string key, std::string new_key,
const CommandControl& command_control) = 0;
367 virtual RequestRpop Rpop(std::string key,
const CommandControl& command_control) = 0;
369 virtual RequestRpush Rpush(std::string key, std::string value,
const CommandControl& command_control) = 0;
371 virtual RequestRpush Rpush(
373 std::vector<std::string> values,
377 virtual RequestRpushx Rpushx(std::string key, std::string element,
const CommandControl& command_control) = 0;
383 virtual RequestSadd
Sadd(std::string key, std::string member,
const CommandControl& command_control) = 0;
388 std::vector<std::string> members,
396 virtual RequestScan
Scan(size_t shard, ScanOptions options,
const CommandControl& command_control) = 0;
398 virtual RequestScard Scard(std::string key,
const CommandControl& command_control) = 0;
400 virtual RequestSet Set(std::string key, std::string value,
const CommandControl& command_control) = 0;
402 virtual RequestSet Set(
405 std::chrono::milliseconds ttl,
409 virtual RequestSetIfExist SetIfExist(std::string key, std::string value,
const CommandControl& command_control) = 0;
411 virtual RequestSetIfExist SetIfExist(
414 std::chrono::milliseconds ttl,
418 virtual RequestSetIfNotExist SetIfNotExist(
424 virtual RequestSetIfNotExist SetIfNotExist(
427 std::chrono::milliseconds ttl,
431 virtual RequestSetIfNotExistOrGet SetIfNotExistOrGet(
437 virtual RequestSetIfNotExistOrGet SetIfNotExistOrGet(
440 std::chrono::milliseconds ttl,
444 virtual RequestSetex Setex(
446 std::chrono::seconds seconds,
451 virtual RequestSismember Sismember(std::string key, std::string member,
const CommandControl& command_control) = 0;
454 virtual RequestSmembers Smembers(std::string key,
const CommandControl& command_control) = 0;
456 virtual RequestSrandmember Srandmember(std::string key,
const CommandControl& command_control) = 0;
458 virtual RequestSrandmembers Srandmembers(std::string key, int64_t count,
const CommandControl& command_control) = 0;
460 virtual RequestSrem Srem(std::string key, std::string member,
const CommandControl& command_control) = 0;
462 virtual RequestSrem Srem(
464 std::vector<std::string> members,
472 virtual RequestSscan
Sscan(std::string key, SscanOptions options,
const CommandControl& command_control) = 0;
474 virtual RequestStrlen Strlen(std::string key,
const CommandControl& command_control) = 0;
476 virtual RequestTime Time(size_t shard,
const CommandControl& command_control) = 0;
478 virtual RequestTtl Ttl(std::string key,
const CommandControl& command_control) = 0;
480 virtual RequestType Type(std::string key,
const CommandControl& command_control) = 0;
482 virtual RequestZadd Zadd(
489 virtual RequestZadd Zadd(
497 virtual RequestZadd Zadd(
499 std::vector<std::pair<
double, std::string>> scored_members,
503 virtual RequestZadd Zadd(
505 std::vector<std::pair<
double, std::string>> scored_members,
510 virtual RequestZaddIncr ZaddIncr(
517 virtual RequestZaddIncrExisting ZaddIncrExisting(
524 virtual RequestZcard Zcard(std::string key,
const CommandControl& command_control) = 0;
526 virtual RequestZcount Zcount(std::string key,
double min,
double max,
const CommandControl& command_control) = 0;
528 virtual RequestZrange Zrange(
535 virtual RequestZrangeWithScores ZrangeWithScores(
542 virtual RequestZrangebyscore Zrangebyscore(
549 virtual RequestZrangebyscore Zrangebyscore(
556 virtual RequestZrangebyscore Zrangebyscore(
564 virtual RequestZrangebyscore Zrangebyscore(
572 virtual RequestZrangebyscoreWithScores ZrangebyscoreWithScores(
579 virtual RequestZrangebyscoreWithScores ZrangebyscoreWithScores(
586 virtual RequestZrangebyscoreWithScores ZrangebyscoreWithScores(
594 virtual RequestZrangebyscoreWithScores ZrangebyscoreWithScores(
602 virtual RequestZrem Zrem(std::string key, std::string member,
const CommandControl& command_control) = 0;
604 virtual RequestZrem Zrem(
606 std::vector<std::string> members,
610 virtual RequestZremrangebyrank Zremrangebyrank(
617 virtual RequestZremrangebyscore Zremrangebyscore(
624 virtual RequestZremrangebyscore Zremrangebyscore(
635 virtual RequestZscan
Zscan(std::string key, ZscanOptions options,
const CommandControl& command_control) = 0;
637 virtual RequestZscore Zscore(std::string key, std::string member,
const CommandControl& command_control) = 0;
645 RequestZscore Zscore(
652 void Publish(std::string channel, std::string message,
const CommandControl& command_control);
654 RequestScan Scan(size_t shard,
const CommandControl& command_control);
656 RequestHscan Hscan(std::string key,
const CommandControl& command_control);
658 RequestSscan Sscan(std::string key,
const CommandControl& command_control);
660 RequestZscan Zscan(std::string key,
const CommandControl& command_control);
663 virtual RequestEvalCommon EvalCommon(
665 std::vector<std::string> keys,
666 std::vector<std::string> args,
669 virtual RequestEvalShaCommon EvalShaCommon(
670 std::string script_hash,
671 std::vector<std::string> keys,
672 std::vector<std::string> args,
675 virtual RequestGenericCommon GenericCommon(
677 std::vector<std::string> args,