41 virtual ~Client() =
default;
43 virtual size_t ShardsCount()
const = 0;
44 virtual bool IsInClusterMode()
const = 0;
46 virtual size_t ShardByKey(
const std::string& key)
const = 0;
48 void CheckShardIdx(size_t shard_idx)
const;
54 virtual RequestAppend Append(std::string key, std::string value,
const CommandControl& command_control) = 0;
56 virtual RequestBitop Bitop(
59 std::vector<std::string> src_keys,
63 virtual RequestDbsize Dbsize(size_t shard,
const CommandControl& command_control) = 0;
65 virtual RequestDecr Decr(std::string key,
const CommandControl& command_control) = 0;
67 virtual RequestDel Del(std::string key,
const CommandControl& command_control) = 0;
69 virtual RequestDel Del(std::vector<std::string> keys,
const CommandControl& command_control) = 0;
71 virtual RequestUnlink Unlink(std::string key,
const CommandControl& command_control) = 0;
73 virtual RequestUnlink Unlink(std::vector<std::string> keys,
const CommandControl& command_control) = 0;
81 template <
typename ScriptResult,
typename ReplyType = ScriptResult>
82 RequestEval<ScriptResult, ReplyType>
Eval(
84 std::vector<std::string> keys,
85 std::vector<std::string> args,
88 return RequestEval<ScriptResult, ReplyType>{
89 EvalCommon(std::move(script), std::move(keys), std::move(args), command_control)};
82 RequestEval<ScriptResult, ReplyType>
Eval( {
…}
99 template <
typename ScriptResult,
typename ReplyType = ScriptResult>
100 RequestEvalSha<ScriptResult, ReplyType>
EvalSha(
101 std::string script_hash,
102 std::vector<std::string> keys,
103 std::vector<std::string> args,
106 return RequestEvalSha<ScriptResult, ReplyType>{
107 EvalShaCommon(std::move(script_hash), std::move(keys), std::move(args), command_control)};
100 RequestEvalSha<ScriptResult, ReplyType>
EvalSha( {
…}
117 template <
typename ScriptInfo,
typename ReplyType = std::decay_t<ScriptInfo>>
118 RequestEval<std::decay_t<ScriptInfo>, ReplyType>
Eval(
119 const ScriptInfo& script_info,
120 std::vector<std::string> keys,
121 std::vector<std::string> args,
124 return RequestEval<std::decay_t<ScriptInfo>, ReplyType>{
125 EvalCommon(script_info.GetScript(), std::move(keys), std::move(args), command_control)};
118 RequestEval<std::decay_t<ScriptInfo>, ReplyType>
Eval( {
…}
128 virtual RequestExists Exists(std::string key,
const CommandControl& command_control) = 0;
130 virtual RequestExists Exists(std::vector<std::string> keys,
const CommandControl& command_control) = 0;
132 virtual RequestExpire Expire(std::string key, std::chrono::seconds ttl,
const CommandControl& command_control) = 0;
134 virtual RequestGeoadd Geoadd(std::string key,
GeoaddArg point_member,
const CommandControl& command_control) = 0;
136 virtual RequestGeoadd
139 virtual RequestGeoradius Georadius(
148 virtual RequestGeosearch Geosearch(
156 virtual RequestGeosearch Geosearch(
165 virtual RequestGeosearch Geosearch(
174 virtual RequestGeosearch Geosearch(
184 virtual RequestGet Get(std::string key,
const CommandControl& command_control) = 0;
186 virtual RequestGetset Getset(std::string key, std::string value,
const CommandControl& command_control) = 0;
188 virtual RequestHdel Hdel(std::string key, std::string field,
const CommandControl& command_control) = 0;
191 Hdel(std::string key, std::vector<std::string> fields,
const CommandControl& command_control) = 0;
193 virtual RequestHexists Hexists(std::string key, std::string field,
const CommandControl& command_control) = 0;
195 virtual RequestHget Hget(std::string key, std::string field,
const CommandControl& command_control) = 0;
198 virtual RequestHgetall Hgetall(std::string key,
const CommandControl& command_control) = 0;
200 virtual RequestHincrby
201 Hincrby(std::string key, std::string field, int64_t increment,
const CommandControl& command_control) = 0;
203 virtual RequestHincrbyfloat
204 Hincrbyfloat(std::string key, std::string field,
double increment,
const CommandControl& command_control) = 0;
207 virtual RequestHkeys Hkeys(std::string key,
const CommandControl& command_control) = 0;
209 virtual RequestHlen Hlen(std::string key,
const CommandControl& command_control) = 0;
212 Hmget(std::string key, std::vector<std::string> fields,
const CommandControl& command_control) = 0;
214 virtual RequestHmset Hmset(
216 std::vector<std::pair<std::string, std::string>> field_values,
224 virtual RequestHscan
Hscan(std::string key, HscanOptions options,
const CommandControl& command_control) = 0;
227 Hset(std::string key, std::string field, std::string value,
const CommandControl& command_control) = 0;
229 virtual RequestHsetnx
230 Hsetnx(std::string key, std::string field, std::string value,
const CommandControl& command_control) = 0;
233 virtual RequestHvals Hvals(std::string key,
const CommandControl& command_control) = 0;
235 virtual RequestIncr Incr(std::string key,
const CommandControl& command_control) = 0;
237 [[
deprecated(
"use Scan")]]
virtual RequestKeys
238 Keys(std::string keys_pattern, size_t shard,
const CommandControl& command_control) = 0;
240 virtual RequestLindex Lindex(std::string key, int64_t index,
const CommandControl& command_control) = 0;
242 virtual RequestLlen Llen(std::string key,
const CommandControl& command_control) = 0;
244 virtual RequestLpop Lpop(std::string key,
const CommandControl& command_control) = 0;
246 virtual RequestLpush Lpush(std::string key, std::string value,
const CommandControl& command_control) = 0;
249 Lpush(std::string key, std::vector<std::string> values,
const CommandControl& command_control) = 0;
251 virtual RequestLpushx Lpushx(std::string key, std::string element,
const CommandControl& command_control) = 0;
253 virtual RequestLrange
254 Lrange(std::string key, int64_t start, int64_t stop,
const CommandControl& command_control) = 0;
257 Lrem(std::string key, int64_t count, std::string element,
const CommandControl& command_control) = 0;
259 virtual RequestLtrim Ltrim(std::string key, int64_t start, int64_t stop,
const CommandControl& command_control) = 0;
261 virtual RequestMget Mget(std::vector<std::string> keys,
const CommandControl& command_control) = 0;
264 Mset(std::vector<std::pair<std::string, std::string>> key_values,
const CommandControl& command_control) = 0;
266 virtual TransactionPtr Multi() = 0;
268 virtual TransactionPtr Multi(
Transaction::CheckShards check_shards) = 0;
270 virtual RequestPersist Persist(std::string key,
const CommandControl& command_control) = 0;
272 virtual RequestPexpire
273 Pexpire(std::string key, std::chrono::milliseconds ttl,
const CommandControl& command_control) = 0;
275 virtual RequestPing Ping(size_t shard,
const CommandControl& command_control) = 0;
277 virtual RequestPingMessage Ping(size_t shard, std::string message,
const CommandControl& command_control) = 0;
280 Publish(std::string channel, std::string message,
const CommandControl& command_control, PubShard policy) = 0;
282 virtual void Spublish(std::string channel, std::string message,
const CommandControl& command_control) = 0;
284 virtual RequestRename Rename(std::string key, std::string new_key,
const CommandControl& command_control) = 0;
286 virtual RequestRpop Rpop(std::string key,
const CommandControl& command_control) = 0;
288 virtual RequestRpush Rpush(std::string key, std::string value,
const CommandControl& command_control) = 0;
291 Rpush(std::string key, std::vector<std::string> values,
const CommandControl& command_control) = 0;
293 virtual RequestRpushx Rpushx(std::string key, std::string element,
const CommandControl& command_control) = 0;
299 virtual RequestSadd
Sadd(std::string key, std::string member,
const CommandControl& command_control) = 0;
309 virtual RequestScan
Scan(size_t shard, ScanOptions options,
const CommandControl& command_control) = 0;
311 virtual RequestScard Scard(std::string key,
const CommandControl& command_control) = 0;
313 virtual RequestSet Set(std::string key, std::string value,
const CommandControl& command_control) = 0;
316 Set(std::string key, std::string value, std::chrono::milliseconds ttl,
const CommandControl& command_control) = 0;
318 virtual RequestSetIfExist SetIfExist(std::string key, std::string value,
const CommandControl& command_control) = 0;
320 virtual RequestSetIfExist SetIfExist(
323 std::chrono::milliseconds ttl,
327 virtual RequestSetIfNotExist
328 SetIfNotExist(std::string key, std::string value,
const CommandControl& command_control) = 0;
330 virtual RequestSetIfNotExist SetIfNotExist(
333 std::chrono::milliseconds ttl,
338 Setex(std::string key, std::chrono::seconds seconds, std::string value,
const CommandControl& command_control) = 0;
340 virtual RequestSismember Sismember(std::string key, std::string member,
const CommandControl& command_control) = 0;
343 virtual RequestSmembers Smembers(std::string key,
const CommandControl& command_control) = 0;
345 virtual RequestSrandmember Srandmember(std::string key,
const CommandControl& command_control) = 0;
347 virtual RequestSrandmembers Srandmembers(std::string key, int64_t count,
const CommandControl& command_control) = 0;
349 virtual RequestSrem Srem(std::string key, std::string member,
const CommandControl& command_control) = 0;
352 Srem(std::string key, std::vector<std::string> members,
const CommandControl& command_control) = 0;
358 virtual RequestSscan
Sscan(std::string key, SscanOptions options,
const CommandControl& command_control) = 0;
360 virtual RequestStrlen Strlen(std::string key,
const CommandControl& command_control) = 0;
362 virtual RequestTime Time(size_t shard,
const CommandControl& command_control) = 0;
364 virtual RequestTtl Ttl(std::string key,
const CommandControl& command_control) = 0;
366 virtual RequestType Type(std::string key,
const CommandControl& command_control) = 0;
369 Zadd(std::string key,
double score, std::string member,
const CommandControl& command_control) = 0;
371 virtual RequestZadd Zadd(
379 virtual RequestZadd Zadd(
381 std::vector<std::pair<
double, std::string>> scored_members,
385 virtual RequestZadd Zadd(
387 std::vector<std::pair<
double, std::string>> scored_members,
392 virtual RequestZaddIncr
393 ZaddIncr(std::string key,
double score, std::string member,
const CommandControl& command_control) = 0;
395 virtual RequestZaddIncrExisting
396 ZaddIncrExisting(std::string key,
double score, std::string member,
const CommandControl& command_control) = 0;
398 virtual RequestZcard Zcard(std::string key,
const CommandControl& command_control) = 0;
400 virtual RequestZcount Zcount(std::string key,
double min,
double max,
const CommandControl& command_control) = 0;
402 virtual RequestZrange
403 Zrange(std::string key, int64_t start, int64_t stop,
const CommandControl& command_control) = 0;
405 virtual RequestZrangeWithScores
406 ZrangeWithScores(std::string key, int64_t start, int64_t stop,
const CommandControl& command_control) = 0;
408 virtual RequestZrangebyscore
409 Zrangebyscore(std::string key,
double min,
double max,
const CommandControl& command_control) = 0;
411 virtual RequestZrangebyscore
412 Zrangebyscore(std::string key, std::string min, std::string max,
const CommandControl& command_control) = 0;
414 virtual RequestZrangebyscore Zrangebyscore(
422 virtual RequestZrangebyscore Zrangebyscore(
430 virtual RequestZrangebyscoreWithScores
431 ZrangebyscoreWithScores(std::string key,
double min,
double max,
const CommandControl& command_control) = 0;
433 virtual RequestZrangebyscoreWithScores ZrangebyscoreWithScores(
440 virtual RequestZrangebyscoreWithScores ZrangebyscoreWithScores(
448 virtual RequestZrangebyscoreWithScores ZrangebyscoreWithScores(
456 virtual RequestZrem Zrem(std::string key, std::string member,
const CommandControl& command_control) = 0;
459 Zrem(std::string key, std::vector<std::string> members,
const CommandControl& command_control) = 0;
461 virtual RequestZremrangebyrank
462 Zremrangebyrank(std::string key, int64_t start, int64_t stop,
const CommandControl& command_control) = 0;
464 virtual RequestZremrangebyscore
465 Zremrangebyscore(std::string key,
double min,
double max,
const CommandControl& command_control) = 0;
467 virtual RequestZremrangebyscore
468 Zremrangebyscore(std::string key, std::string min, std::string max,
const CommandControl& command_control) = 0;
474 virtual RequestZscan
Zscan(std::string key, ZscanOptions options,
const CommandControl& command_control) = 0;
476 virtual RequestZscore Zscore(std::string key, std::string member,
const CommandControl& command_control) = 0;
487 void Publish(std::string channel, std::string message,
const CommandControl& command_control);
489 RequestScan Scan(size_t shard,
const CommandControl& command_control);
491 RequestHscan Hscan(std::string key,
const CommandControl& command_control);
493 RequestSscan Sscan(std::string key,
const CommandControl& command_control);
495 RequestZscan Zscan(std::string key,
const CommandControl& command_control);
498 virtual RequestEvalCommon EvalCommon(
500 std::vector<std::string> keys,
501 std::vector<std::string> args,
504 virtual RequestEvalShaCommon EvalShaCommon(
505 std::string script_hash,
506 std::vector<std::string> keys,
507 std::vector<std::string> args,