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)};
100 template <
typename ScriptResult,
typename ReplyType = ScriptResult>
101 RequestEvalSha<ScriptResult, ReplyType>
EvalSha(
102 std::string script_hash,
103 std::vector<std::string> keys,
104 std::vector<std::string> args,
107 return RequestEvalSha<ScriptResult, ReplyType>{
108 EvalShaCommon(std::move(script_hash), std::move(keys), std::move(args), command_control)};
116 template <
typename ReplyType>
119 std::vector<std::string> args,
123 return RequestGeneric<ReplyType>{
124 GenericCommon(std::move(command), std::move(args), key_index, command_control)};
134 template <
typename ScriptInfo,
typename ReplyType = std::decay_t<ScriptInfo>>
135 RequestEval<std::decay_t<ScriptInfo>, ReplyType>
Eval(
136 const ScriptInfo& script_info,
137 std::vector<std::string> keys,
138 std::vector<std::string> args,
141 return RequestEval<std::decay_t<ScriptInfo>, ReplyType>{
142 EvalCommon(script_info.GetScript(), std::move(keys), std::move(args), command_control)};
145 virtual RequestExists Exists(std::string key,
const CommandControl& command_control) = 0;
147 virtual RequestExists Exists(std::vector<std::string> keys,
const CommandControl& command_control) = 0;
149 virtual RequestExpire Expire(std::string key, std::chrono::seconds ttl,
const CommandControl& command_control) = 0;
151 virtual RequestGeoadd Geoadd(std::string key,
GeoaddArg point_member,
const CommandControl& command_control) = 0;
153 virtual RequestGeoadd
156 virtual RequestGeoradius Georadius(
165 virtual RequestGeosearch Geosearch(
173 virtual RequestGeosearch Geosearch(
182 virtual RequestGeosearch Geosearch(
191 virtual RequestGeosearch Geosearch(
201 virtual RequestGet Get(std::string key,
const CommandControl& command_control) = 0;
203 virtual RequestGetset Getset(std::string key, std::string value,
const CommandControl& command_control) = 0;
205 virtual RequestHdel Hdel(std::string key, std::string field,
const CommandControl& command_control) = 0;
208 Hdel(std::string key, std::vector<std::string> fields,
const CommandControl& command_control) = 0;
210 virtual RequestHexists Hexists(std::string key, std::string field,
const CommandControl& command_control) = 0;
212 virtual RequestHget Hget(std::string key, std::string field,
const CommandControl& command_control) = 0;
215 virtual RequestHgetall Hgetall(std::string key,
const CommandControl& command_control) = 0;
217 virtual RequestHincrby
218 Hincrby(std::string key, std::string field, int64_t increment,
const CommandControl& command_control) = 0;
220 virtual RequestHincrbyfloat
221 Hincrbyfloat(std::string key, std::string field,
double increment,
const CommandControl& command_control) = 0;
224 virtual RequestHkeys Hkeys(std::string key,
const CommandControl& command_control) = 0;
226 virtual RequestHlen Hlen(std::string key,
const CommandControl& command_control) = 0;
229 Hmget(std::string key, std::vector<std::string> fields,
const CommandControl& command_control) = 0;
231 virtual RequestHmset Hmset(
233 std::vector<std::pair<std::string, std::string>> field_values,
241 virtual RequestHscan
Hscan(std::string key, HscanOptions options,
const CommandControl& command_control) = 0;
244 Hset(std::string key, std::string field, std::string value,
const CommandControl& command_control) = 0;
246 virtual RequestHsetnx
247 Hsetnx(std::string key, std::string field, std::string value,
const CommandControl& command_control) = 0;
250 virtual RequestHvals Hvals(std::string key,
const CommandControl& command_control) = 0;
252 virtual RequestIncr Incr(std::string key,
const CommandControl& command_control) = 0;
254 [[
deprecated(
"use Scan")]]
virtual RequestKeys
255 Keys(std::string keys_pattern, size_t shard,
const CommandControl& command_control) = 0;
257 virtual RequestLindex Lindex(std::string key, int64_t index,
const CommandControl& command_control) = 0;
259 virtual RequestLlen Llen(std::string key,
const CommandControl& command_control) = 0;
261 virtual RequestLpop Lpop(std::string key,
const CommandControl& command_control) = 0;
263 virtual RequestLpush Lpush(std::string key, std::string value,
const CommandControl& command_control) = 0;
266 Lpush(std::string key, std::vector<std::string> values,
const CommandControl& command_control) = 0;
268 virtual RequestLpushx Lpushx(std::string key, std::string element,
const CommandControl& command_control) = 0;
270 virtual RequestLrange
271 Lrange(std::string key, int64_t start, int64_t stop,
const CommandControl& command_control) = 0;
274 Lrem(std::string key, int64_t count, std::string element,
const CommandControl& command_control) = 0;
276 virtual RequestLtrim Ltrim(std::string key, int64_t start, int64_t stop,
const CommandControl& command_control) = 0;
278 virtual RequestMget Mget(std::vector<std::string> keys,
const CommandControl& command_control) = 0;
281 Mset(std::vector<std::pair<std::string, std::string>> key_values,
const CommandControl& command_control) = 0;
283 virtual TransactionPtr Multi() = 0;
285 virtual TransactionPtr Multi(
Transaction::CheckShards check_shards) = 0;
287 virtual RequestPersist Persist(std::string key,
const CommandControl& command_control) = 0;
289 virtual RequestPexpire
290 Pexpire(std::string key, std::chrono::milliseconds ttl,
const CommandControl& command_control) = 0;
292 virtual RequestPing Ping(size_t shard,
const CommandControl& command_control) = 0;
294 virtual RequestPingMessage Ping(size_t shard, std::string message,
const CommandControl& command_control) = 0;
297 Publish(std::string channel, std::string message,
const CommandControl& command_control, PubShard policy) = 0;
299 virtual void Spublish(std::string channel, std::string message,
const CommandControl& command_control) = 0;
301 virtual RequestRename Rename(std::string key, std::string new_key,
const CommandControl& command_control) = 0;
303 virtual RequestRpop Rpop(std::string key,
const CommandControl& command_control) = 0;
305 virtual RequestRpush Rpush(std::string key, std::string value,
const CommandControl& command_control) = 0;
308 Rpush(std::string key, std::vector<std::string> values,
const CommandControl& command_control) = 0;
310 virtual RequestRpushx Rpushx(std::string key, std::string element,
const CommandControl& command_control) = 0;
316 virtual RequestSadd
Sadd(std::string key, std::string member,
const CommandControl& command_control) = 0;
326 virtual RequestScan
Scan(size_t shard, ScanOptions options,
const CommandControl& command_control) = 0;
328 virtual RequestScard Scard(std::string key,
const CommandControl& command_control) = 0;
330 virtual RequestSet Set(std::string key, std::string value,
const CommandControl& command_control) = 0;
333 Set(std::string key, std::string value, std::chrono::milliseconds ttl,
const CommandControl& command_control) = 0;
335 virtual RequestSetIfExist SetIfExist(std::string key, std::string value,
const CommandControl& command_control) = 0;
337 virtual RequestSetIfExist SetIfExist(
340 std::chrono::milliseconds ttl,
344 virtual RequestSetIfNotExist
345 SetIfNotExist(std::string key, std::string value,
const CommandControl& command_control) = 0;
347 virtual RequestSetIfNotExist SetIfNotExist(
350 std::chrono::milliseconds ttl,
354 virtual RequestSetIfNotExistOrGet
355 SetIfNotExistOrGet(std::string key, std::string value,
const CommandControl& command_control) = 0;
357 virtual RequestSetIfNotExistOrGet SetIfNotExistOrGet(
360 std::chrono::milliseconds ttl,
365 Setex(std::string key, std::chrono::seconds seconds, std::string value,
const CommandControl& command_control) = 0;
367 virtual RequestSismember Sismember(std::string key, std::string member,
const CommandControl& command_control) = 0;
370 virtual RequestSmembers Smembers(std::string key,
const CommandControl& command_control) = 0;
372 virtual RequestSrandmember Srandmember(std::string key,
const CommandControl& command_control) = 0;
374 virtual RequestSrandmembers Srandmembers(std::string key, int64_t count,
const CommandControl& command_control) = 0;
376 virtual RequestSrem Srem(std::string key, std::string member,
const CommandControl& command_control) = 0;
379 Srem(std::string key, std::vector<std::string> members,
const CommandControl& command_control) = 0;
385 virtual RequestSscan
Sscan(std::string key, SscanOptions options,
const CommandControl& command_control) = 0;
387 virtual RequestStrlen Strlen(std::string key,
const CommandControl& command_control) = 0;
389 virtual RequestTime Time(size_t shard,
const CommandControl& command_control) = 0;
391 virtual RequestTtl Ttl(std::string key,
const CommandControl& command_control) = 0;
393 virtual RequestType Type(std::string key,
const CommandControl& command_control) = 0;
396 Zadd(std::string key,
double score, std::string member,
const CommandControl& command_control) = 0;
398 virtual RequestZadd Zadd(
406 virtual RequestZadd Zadd(
408 std::vector<std::pair<
double, std::string>> scored_members,
412 virtual RequestZadd Zadd(
414 std::vector<std::pair<
double, std::string>> scored_members,
419 virtual RequestZaddIncr
420 ZaddIncr(std::string key,
double score, std::string member,
const CommandControl& command_control) = 0;
422 virtual RequestZaddIncrExisting
423 ZaddIncrExisting(std::string key,
double score, std::string member,
const CommandControl& command_control) = 0;
425 virtual RequestZcard Zcard(std::string key,
const CommandControl& command_control) = 0;
427 virtual RequestZcount Zcount(std::string key,
double min,
double max,
const CommandControl& command_control) = 0;
429 virtual RequestZrange
430 Zrange(std::string key, int64_t start, int64_t stop,
const CommandControl& command_control) = 0;
432 virtual RequestZrangeWithScores
433 ZrangeWithScores(std::string key, int64_t start, int64_t stop,
const CommandControl& command_control) = 0;
435 virtual RequestZrangebyscore
436 Zrangebyscore(std::string key,
double min,
double max,
const CommandControl& command_control) = 0;
438 virtual RequestZrangebyscore
439 Zrangebyscore(std::string key, std::string min, std::string max,
const CommandControl& command_control) = 0;
441 virtual RequestZrangebyscore Zrangebyscore(
449 virtual RequestZrangebyscore Zrangebyscore(
457 virtual RequestZrangebyscoreWithScores
458 ZrangebyscoreWithScores(std::string key,
double min,
double max,
const CommandControl& command_control) = 0;
460 virtual RequestZrangebyscoreWithScores ZrangebyscoreWithScores(
467 virtual RequestZrangebyscoreWithScores ZrangebyscoreWithScores(
475 virtual RequestZrangebyscoreWithScores ZrangebyscoreWithScores(
483 virtual RequestZrem Zrem(std::string key, std::string member,
const CommandControl& command_control) = 0;
486 Zrem(std::string key, std::vector<std::string> members,
const CommandControl& command_control) = 0;
488 virtual RequestZremrangebyrank
489 Zremrangebyrank(std::string key, int64_t start, int64_t stop,
const CommandControl& command_control) = 0;
491 virtual RequestZremrangebyscore
492 Zremrangebyscore(std::string key,
double min,
double max,
const CommandControl& command_control) = 0;
494 virtual RequestZremrangebyscore
495 Zremrangebyscore(std::string key, std::string min, std::string max,
const CommandControl& command_control) = 0;
501 virtual RequestZscan
Zscan(std::string key, ZscanOptions options,
const CommandControl& command_control) = 0;
503 virtual RequestZscore Zscore(std::string key, std::string member,
const CommandControl& command_control) = 0;
514 void Publish(std::string channel, std::string message,
const CommandControl& command_control);
516 RequestScan Scan(size_t shard,
const CommandControl& command_control);
518 RequestHscan Hscan(std::string key,
const CommandControl& command_control);
520 RequestSscan Sscan(std::string key,
const CommandControl& command_control);
522 RequestZscan Zscan(std::string key,
const CommandControl& command_control);
525 virtual RequestEvalCommon EvalCommon(
527 std::vector<std::string> keys,
528 std::vector<std::string> args,
531 virtual RequestEvalShaCommon EvalShaCommon(
532 std::string script_hash,
533 std::vector<std::string> keys,
534 std::vector<std::string> args,
537 virtual RequestGenericCommon GenericCommon(
539 std::vector<std::string> args,