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;
50 virtual const std::string& GetAnyKeyForShard(size_t shard_idx)
const = 0;
52 virtual std::shared_ptr<
Client> GetClientForShard(size_t shard_idx) = 0;
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)};
86 RequestEval<ScriptResult, ReplyType>
Eval( {
…}
103 template <
typename ScriptResult,
typename ReplyType = ScriptResult>
104 RequestEvalSha<ScriptResult, ReplyType>
EvalSha(
105 std::string script_hash,
106 std::vector<std::string> keys,
107 std::vector<std::string> args,
110 return RequestEvalSha<ScriptResult, ReplyType>{
111 EvalShaCommon(std::move(script_hash), std::move(keys), std::move(args), command_control)};
104 RequestEvalSha<ScriptResult, ReplyType>
EvalSha( {
…}
121 template <
typename ScriptInfo,
typename ReplyType = std::decay_t<ScriptInfo>>
122 RequestEval<std::decay_t<ScriptInfo>, ReplyType>
Eval(
123 const ScriptInfo& script_info,
124 std::vector<std::string> keys,
125 std::vector<std::string> args,
128 return RequestEval<std::decay_t<ScriptInfo>, ReplyType>{
129 EvalCommon(script_info.GetScript(), std::move(keys), std::move(args), command_control)};
122 RequestEval<std::decay_t<ScriptInfo>, ReplyType>
Eval( {
…}
132 virtual RequestExists Exists(std::string key,
const CommandControl& command_control) = 0;
134 virtual RequestExists Exists(std::vector<std::string> keys,
const CommandControl& command_control) = 0;
136 virtual RequestExpire Expire(std::string key, std::chrono::seconds ttl,
const CommandControl& command_control) = 0;
138 virtual RequestGeoadd Geoadd(std::string key,
GeoaddArg point_member,
const CommandControl& command_control) = 0;
140 virtual RequestGeoadd
143 virtual RequestGeoradius Georadius(
152 virtual RequestGeosearch Geosearch(
160 virtual RequestGeosearch Geosearch(
169 virtual RequestGeosearch Geosearch(
178 virtual RequestGeosearch Geosearch(
188 virtual RequestGet Get(std::string key,
const CommandControl& command_control) = 0;
190 virtual RequestGetset Getset(std::string key, std::string value,
const CommandControl& command_control) = 0;
192 virtual RequestHdel Hdel(std::string key, std::string field,
const CommandControl& command_control) = 0;
195 Hdel(std::string key, std::vector<std::string> fields,
const CommandControl& command_control) = 0;
197 virtual RequestHexists Hexists(std::string key, std::string field,
const CommandControl& command_control) = 0;
199 virtual RequestHget Hget(std::string key, std::string field,
const CommandControl& command_control) = 0;
202 virtual RequestHgetall Hgetall(std::string key,
const CommandControl& command_control) = 0;
204 virtual RequestHincrby
205 Hincrby(std::string key, std::string field, int64_t increment,
const CommandControl& command_control) = 0;
207 virtual RequestHincrbyfloat
208 Hincrbyfloat(std::string key, std::string field,
double increment,
const CommandControl& command_control) = 0;
211 virtual RequestHkeys Hkeys(std::string key,
const CommandControl& command_control) = 0;
213 virtual RequestHlen Hlen(std::string key,
const CommandControl& command_control) = 0;
216 Hmget(std::string key, std::vector<std::string> fields,
const CommandControl& command_control) = 0;
218 virtual RequestHmset Hmset(
220 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;
295 virtual RequestSadd Sadd(std::string key, std::string member,
const CommandControl& command_control) = 0;
298 Sadd(std::string key, std::vector<std::string> members,
const CommandControl& command_control) = 0;
300 virtual RequestScan Scan(size_t shard, ScanOptions options,
const CommandControl& command_control) = 0;
302 virtual RequestScard Scard(std::string key,
const CommandControl& command_control) = 0;
304 virtual RequestSet Set(std::string key, std::string value,
const CommandControl& command_control) = 0;
307 Set(std::string key, std::string value, std::chrono::milliseconds ttl,
const CommandControl& command_control) = 0;
309 virtual RequestSetIfExist SetIfExist(std::string key, std::string value,
const CommandControl& command_control) = 0;
311 virtual RequestSetIfExist SetIfExist(
314 std::chrono::milliseconds ttl,
318 virtual RequestSetIfNotExist
319 SetIfNotExist(std::string key, std::string value,
const CommandControl& command_control) = 0;
321 virtual RequestSetIfNotExist SetIfNotExist(
324 std::chrono::milliseconds ttl,
329 Setex(std::string key, std::chrono::seconds seconds, std::string value,
const CommandControl& command_control) = 0;
331 virtual RequestSismember Sismember(std::string key, std::string member,
const CommandControl& command_control) = 0;
334 virtual RequestSmembers Smembers(std::string key,
const CommandControl& command_control) = 0;
336 virtual RequestSrandmember Srandmember(std::string key,
const CommandControl& command_control) = 0;
338 virtual RequestSrandmembers Srandmembers(std::string key, int64_t count,
const CommandControl& command_control) = 0;
340 virtual RequestSrem Srem(std::string key, std::string member,
const CommandControl& command_control) = 0;
343 Srem(std::string key, std::vector<std::string> members,
const CommandControl& command_control) = 0;
345 virtual RequestSscan Sscan(std::string key, SscanOptions options,
const CommandControl& command_control) = 0;
347 virtual RequestStrlen Strlen(std::string key,
const CommandControl& command_control) = 0;
349 virtual RequestTime Time(size_t shard,
const CommandControl& command_control) = 0;
351 virtual RequestTtl Ttl(std::string key,
const CommandControl& command_control) = 0;
353 virtual RequestType Type(std::string key,
const CommandControl& command_control) = 0;
356 Zadd(std::string key,
double score, std::string member,
const CommandControl& command_control) = 0;
358 virtual RequestZadd Zadd(
366 virtual RequestZadd Zadd(
368 std::vector<std::pair<
double, std::string>> scored_members,
372 virtual RequestZadd Zadd(
374 std::vector<std::pair<
double, std::string>> scored_members,
379 virtual RequestZaddIncr
380 ZaddIncr(std::string key,
double score, std::string member,
const CommandControl& command_control) = 0;
382 virtual RequestZaddIncrExisting
383 ZaddIncrExisting(std::string key,
double score, std::string member,
const CommandControl& command_control) = 0;
385 virtual RequestZcard Zcard(std::string key,
const CommandControl& command_control) = 0;
387 virtual RequestZcount Zcount(std::string key,
double min,
double max,
const CommandControl& command_control) = 0;
389 virtual RequestZrange
390 Zrange(std::string key, int64_t start, int64_t stop,
const CommandControl& command_control) = 0;
392 virtual RequestZrangeWithScores
393 ZrangeWithScores(std::string key, int64_t start, int64_t stop,
const CommandControl& command_control) = 0;
395 virtual RequestZrangebyscore
396 Zrangebyscore(std::string key,
double min,
double max,
const CommandControl& command_control) = 0;
398 virtual RequestZrangebyscore
399 Zrangebyscore(std::string key, std::string min, std::string max,
const CommandControl& command_control) = 0;
401 virtual RequestZrangebyscore Zrangebyscore(
409 virtual RequestZrangebyscore Zrangebyscore(
417 virtual RequestZrangebyscoreWithScores
418 ZrangebyscoreWithScores(std::string key,
double min,
double max,
const CommandControl& command_control) = 0;
420 virtual RequestZrangebyscoreWithScores ZrangebyscoreWithScores(
427 virtual RequestZrangebyscoreWithScores ZrangebyscoreWithScores(
435 virtual RequestZrangebyscoreWithScores ZrangebyscoreWithScores(
443 virtual RequestZrem Zrem(std::string key, std::string member,
const CommandControl& command_control) = 0;
446 Zrem(std::string key, std::vector<std::string> members,
const CommandControl& command_control) = 0;
448 virtual RequestZremrangebyrank
449 Zremrangebyrank(std::string key, int64_t start, int64_t stop,
const CommandControl& command_control) = 0;
451 virtual RequestZremrangebyscore
452 Zremrangebyscore(std::string key,
double min,
double max,
const CommandControl& command_control) = 0;
454 virtual RequestZremrangebyscore
455 Zremrangebyscore(std::string key, std::string min, std::string max,
const CommandControl& command_control) = 0;
457 virtual RequestZscan Zscan(std::string key, ZscanOptions options,
const CommandControl& command_control) = 0;
459 virtual RequestZscore Zscore(std::string key, std::string member,
const CommandControl& command_control) = 0;
470 void Publish(std::string channel, std::string message,
const CommandControl& command_control);
472 RequestScan Scan(size_t shard,
const CommandControl& command_control);
474 RequestHscan Hscan(std::string key,
const CommandControl& command_control);
476 RequestSscan Sscan(std::string key,
const CommandControl& command_control);
478 RequestZscan Zscan(std::string key,
const CommandControl& command_control);
481 virtual RequestEvalCommon EvalCommon(
483 std::vector<std::string> keys,
484 std::vector<std::string> args,
487 virtual RequestEvalShaCommon EvalShaCommon(
488 std::string script_hash,
489 std::vector<std::string> keys,
490 std::vector<std::string> args,