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,
220 virtual RequestHscan Hscan(std::string key, HscanOptions options,
const CommandControl& command_control) = 0;
223 Hset(std::string key, std::string field, std::string value,
const CommandControl& command_control) = 0;
225 virtual RequestHsetnx
226 Hsetnx(std::string key, std::string field, std::string value,
const CommandControl& command_control) = 0;
229 virtual RequestHvals Hvals(std::string key,
const CommandControl& command_control) = 0;
231 virtual RequestIncr Incr(std::string key,
const CommandControl& command_control) = 0;
233 [[
deprecated(
"use Scan")]]
virtual RequestKeys
234 Keys(std::string keys_pattern, size_t shard,
const CommandControl& command_control) = 0;
236 virtual RequestLindex Lindex(std::string key, int64_t index,
const CommandControl& command_control) = 0;
238 virtual RequestLlen Llen(std::string key,
const CommandControl& command_control) = 0;
240 virtual RequestLpop Lpop(std::string key,
const CommandControl& command_control) = 0;
242 virtual RequestLpush Lpush(std::string key, std::string value,
const CommandControl& command_control) = 0;
245 Lpush(std::string key, std::vector<std::string> values,
const CommandControl& command_control) = 0;
247 virtual RequestLpushx Lpushx(std::string key, std::string element,
const CommandControl& command_control) = 0;
249 virtual RequestLrange
250 Lrange(std::string key, int64_t start, int64_t stop,
const CommandControl& command_control) = 0;
253 Lrem(std::string key, int64_t count, std::string element,
const CommandControl& command_control) = 0;
255 virtual RequestLtrim Ltrim(std::string key, int64_t start, int64_t stop,
const CommandControl& command_control) = 0;
257 virtual RequestMget Mget(std::vector<std::string> keys,
const CommandControl& command_control) = 0;
260 Mset(std::vector<std::pair<std::string, std::string>> key_values,
const CommandControl& command_control) = 0;
262 virtual TransactionPtr Multi() = 0;
264 virtual TransactionPtr Multi(
Transaction::CheckShards check_shards) = 0;
266 virtual RequestPersist Persist(std::string key,
const CommandControl& command_control) = 0;
268 virtual RequestPexpire
269 Pexpire(std::string key, std::chrono::milliseconds ttl,
const CommandControl& command_control) = 0;
271 virtual RequestPing Ping(size_t shard,
const CommandControl& command_control) = 0;
273 virtual RequestPingMessage Ping(size_t shard, std::string message,
const CommandControl& command_control) = 0;
276 Publish(std::string channel, std::string message,
const CommandControl& command_control, PubShard policy) = 0;
278 virtual void Spublish(std::string channel, std::string message,
const CommandControl& command_control) = 0;
280 virtual RequestRename Rename(std::string key, std::string new_key,
const CommandControl& command_control) = 0;
282 virtual RequestRpop Rpop(std::string key,
const CommandControl& command_control) = 0;
284 virtual RequestRpush Rpush(std::string key, std::string value,
const CommandControl& command_control) = 0;
287 Rpush(std::string key, std::vector<std::string> values,
const CommandControl& command_control) = 0;
289 virtual RequestRpushx Rpushx(std::string key, std::string element,
const CommandControl& command_control) = 0;
291 virtual RequestSadd Sadd(std::string key, std::string member,
const CommandControl& command_control) = 0;
294 Sadd(std::string key, std::vector<std::string> members,
const CommandControl& command_control) = 0;
296 virtual RequestScan Scan(size_t shard, ScanOptions options,
const CommandControl& command_control) = 0;
298 virtual RequestScard Scard(std::string key,
const CommandControl& command_control) = 0;
300 virtual RequestSet Set(std::string key, std::string value,
const CommandControl& command_control) = 0;
303 Set(std::string key, std::string value, std::chrono::milliseconds ttl,
const CommandControl& command_control) = 0;
305 virtual RequestSetIfExist SetIfExist(std::string key, std::string value,
const CommandControl& command_control) = 0;
307 virtual RequestSetIfExist SetIfExist(
310 std::chrono::milliseconds ttl,
314 virtual RequestSetIfNotExist
315 SetIfNotExist(std::string key, std::string value,
const CommandControl& command_control) = 0;
317 virtual RequestSetIfNotExist SetIfNotExist(
320 std::chrono::milliseconds ttl,
325 Setex(std::string key, std::chrono::seconds seconds, std::string value,
const CommandControl& command_control) = 0;
327 virtual RequestSismember Sismember(std::string key, std::string member,
const CommandControl& command_control) = 0;
330 virtual RequestSmembers Smembers(std::string key,
const CommandControl& command_control) = 0;
332 virtual RequestSrandmember Srandmember(std::string key,
const CommandControl& command_control) = 0;
334 virtual RequestSrandmembers Srandmembers(std::string key, int64_t count,
const CommandControl& command_control) = 0;
336 virtual RequestSrem Srem(std::string key, std::string member,
const CommandControl& command_control) = 0;
339 Srem(std::string key, std::vector<std::string> members,
const CommandControl& command_control) = 0;
341 virtual RequestSscan Sscan(std::string key, SscanOptions options,
const CommandControl& command_control) = 0;
343 virtual RequestStrlen Strlen(std::string key,
const CommandControl& command_control) = 0;
345 virtual RequestTime Time(size_t shard,
const CommandControl& command_control) = 0;
347 virtual RequestTtl Ttl(std::string key,
const CommandControl& command_control) = 0;
349 virtual RequestType Type(std::string key,
const CommandControl& command_control) = 0;
352 Zadd(std::string key,
double score, std::string member,
const CommandControl& command_control) = 0;
354 virtual RequestZadd Zadd(
362 virtual RequestZadd Zadd(
364 std::vector<std::pair<
double, std::string>> scored_members,
368 virtual RequestZadd Zadd(
370 std::vector<std::pair<
double, std::string>> scored_members,
375 virtual RequestZaddIncr
376 ZaddIncr(std::string key,
double score, std::string member,
const CommandControl& command_control) = 0;
378 virtual RequestZaddIncrExisting
379 ZaddIncrExisting(std::string key,
double score, std::string member,
const CommandControl& command_control) = 0;
381 virtual RequestZcard Zcard(std::string key,
const CommandControl& command_control) = 0;
383 virtual RequestZcount Zcount(std::string key,
double min,
double max,
const CommandControl& command_control) = 0;
385 virtual RequestZrange
386 Zrange(std::string key, int64_t start, int64_t stop,
const CommandControl& command_control) = 0;
388 virtual RequestZrangeWithScores
389 ZrangeWithScores(std::string key, int64_t start, int64_t stop,
const CommandControl& command_control) = 0;
391 virtual RequestZrangebyscore
392 Zrangebyscore(std::string key,
double min,
double max,
const CommandControl& command_control) = 0;
394 virtual RequestZrangebyscore
395 Zrangebyscore(std::string key, std::string min, std::string max,
const CommandControl& command_control) = 0;
397 virtual RequestZrangebyscore Zrangebyscore(
405 virtual RequestZrangebyscore Zrangebyscore(
413 virtual RequestZrangebyscoreWithScores
414 ZrangebyscoreWithScores(std::string key,
double min,
double max,
const CommandControl& command_control) = 0;
416 virtual RequestZrangebyscoreWithScores ZrangebyscoreWithScores(
423 virtual RequestZrangebyscoreWithScores ZrangebyscoreWithScores(
431 virtual RequestZrangebyscoreWithScores ZrangebyscoreWithScores(
439 virtual RequestZrem Zrem(std::string key, std::string member,
const CommandControl& command_control) = 0;
442 Zrem(std::string key, std::vector<std::string> members,
const CommandControl& command_control) = 0;
444 virtual RequestZremrangebyrank
445 Zremrangebyrank(std::string key, int64_t start, int64_t stop,
const CommandControl& command_control) = 0;
447 virtual RequestZremrangebyscore
448 Zremrangebyscore(std::string key,
double min,
double max,
const CommandControl& command_control) = 0;
450 virtual RequestZremrangebyscore
451 Zremrangebyscore(std::string key, std::string min, std::string max,
const CommandControl& command_control) = 0;
453 virtual RequestZscan Zscan(std::string key, ZscanOptions options,
const CommandControl& command_control) = 0;
455 virtual RequestZscore Zscore(std::string key, std::string member,
const CommandControl& command_control) = 0;
466 void Publish(std::string channel, std::string message,
const CommandControl& command_control);
468 RequestScan Scan(size_t shard,
const CommandControl& command_control);
470 RequestHscan Hscan(std::string key,
const CommandControl& command_control);
472 RequestSscan Sscan(std::string key,
const CommandControl& command_control);
474 RequestZscan Zscan(std::string key,
const CommandControl& command_control);
477 virtual RequestEvalCommon EvalCommon(
479 std::vector<std::string> keys,
480 std::vector<std::string> args,
483 virtual RequestEvalShaCommon EvalShaCommon(
484 std::string script_hash,
485 std::vector<std::string> keys,
486 std::vector<std::string> args,