9#include <userver/storages/redis/bit_operation.hpp>
10#include <userver/storages/redis/command_options.hpp>
11#include <userver/storages/redis/request.hpp>
13USERVER_NAMESPACE_BEGIN
15namespace storages::
redis {
31 enum class CheckShards { kNo, kSame };
33 virtual ~Transaction() =
default;
41 virtual RequestExec
Exec(
const CommandControl& command_control) = 0;
45 virtual RequestAppend Append(std::string key, std::string value) = 0;
47 virtual RequestBitop Bitop(BitOperation op, std::string dest, std::vector<std::string> srcs) = 0;
49 virtual RequestDbsize Dbsize(size_t shard) = 0;
51 virtual RequestDecr Decr(std::string key) = 0;
53 virtual RequestDel Del(std::string key) = 0;
55 virtual RequestDel Del(std::vector<std::string> keys) = 0;
57 virtual RequestUnlink Unlink(std::string key) = 0;
59 virtual RequestUnlink Unlink(std::vector<std::string> keys) = 0;
61 virtual RequestExists Exists(std::string key) = 0;
63 virtual RequestExists Exists(std::vector<std::string> keys) = 0;
65 virtual RequestExpire Expire(std::string key, std::chrono::seconds ttl) = 0;
67 virtual RequestGeoadd Geoadd(std::string key, GeoaddArg point_member) = 0;
69 virtual RequestGeoadd Geoadd(std::string key, std::vector<GeoaddArg> point_members) = 0;
71 virtual RequestGeoradius Georadius(
76 const GeoradiusOptions& georadius_options
79 virtual RequestGeosearch
80 Geosearch(std::string key, std::string member,
double radius,
const GeosearchOptions& geosearch_options) = 0;
82 virtual RequestGeosearch Geosearch(
87 const GeosearchOptions& geosearch_options
90 virtual RequestGeosearch Geosearch(
95 const GeosearchOptions& geosearch_options
98 virtual RequestGeosearch Geosearch(
104 const GeosearchOptions& geosearch_options
107 virtual RequestGet Get(std::string key) = 0;
109 virtual RequestGetset Getset(std::string key, std::string value) = 0;
111 virtual RequestHdel Hdel(std::string key, std::string field) = 0;
113 virtual RequestHdel Hdel(std::string key, std::vector<std::string> fields) = 0;
115 virtual RequestHexists Hexists(std::string key, std::string field) = 0;
117 virtual RequestHget Hget(std::string key, std::string field) = 0;
119 virtual RequestHgetall Hgetall(std::string key) = 0;
121 virtual RequestHincrby Hincrby(std::string key, std::string field, int64_t increment) = 0;
123 virtual RequestHincrbyfloat Hincrbyfloat(std::string key, std::string field,
double increment) = 0;
125 virtual RequestHkeys Hkeys(std::string key) = 0;
127 virtual RequestHlen Hlen(std::string key) = 0;
129 virtual RequestHmget Hmget(std::string key, std::vector<std::string> fields) = 0;
131 virtual RequestHmset Hmset(std::string key, std::vector<std::pair<std::string, std::string>> field_values) = 0;
133 virtual RequestHset Hset(std::string key, std::string field, std::string value) = 0;
135 virtual RequestHsetnx Hsetnx(std::string key, std::string field, std::string value) = 0;
137 virtual RequestHvals Hvals(std::string key) = 0;
139 virtual RequestIncr Incr(std::string key) = 0;
141 virtual RequestKeys Keys(std::string keys_pattern, size_t shard) = 0;
143 virtual RequestLindex Lindex(std::string key, int64_t index) = 0;
145 virtual RequestLlen Llen(std::string key) = 0;
147 virtual RequestLpop Lpop(std::string key) = 0;
149 virtual RequestLpush Lpush(std::string key, std::string value) = 0;
151 virtual RequestLpush Lpush(std::string key, std::vector<std::string> values) = 0;
153 virtual RequestLpushx Lpushx(std::string key, std::string element) = 0;
155 virtual RequestLrange Lrange(std::string key, int64_t start, int64_t stop) = 0;
157 virtual RequestLrem Lrem(std::string key, int64_t count, std::string element) = 0;
159 virtual RequestLtrim Ltrim(std::string key, int64_t start, int64_t stop) = 0;
161 virtual RequestMget Mget(std::vector<std::string> keys) = 0;
163 virtual RequestMset Mset(std::vector<std::pair<std::string, std::string>> key_values) = 0;
165 virtual RequestPersist Persist(std::string key) = 0;
167 virtual RequestPexpire Pexpire(std::string key, std::chrono::milliseconds ttl) = 0;
169 virtual RequestPing Ping(size_t shard) = 0;
171 virtual RequestPingMessage PingMessage(size_t shard, std::string message) = 0;
173 virtual RequestRename Rename(std::string key, std::string new_key) = 0;
175 virtual RequestRpop Rpop(std::string key) = 0;
177 virtual RequestRpush Rpush(std::string key, std::string value) = 0;
179 virtual RequestRpush Rpush(std::string key, std::vector<std::string> values) = 0;
181 virtual RequestRpushx Rpushx(std::string key, std::string element) = 0;
183 virtual RequestSadd Sadd(std::string key, std::string member) = 0;
185 virtual RequestSadd Sadd(std::string key, std::vector<std::string> members) = 0;
187 virtual RequestScard Scard(std::string key) = 0;
189 virtual RequestSet Set(std::string key, std::string value) = 0;
191 virtual RequestSet Set(std::string key, std::string value, std::chrono::milliseconds ttl) = 0;
193 virtual RequestSetIfExist SetIfExist(std::string key, std::string value) = 0;
195 virtual RequestSetIfExist SetIfExist(std::string key, std::string value, std::chrono::milliseconds ttl) = 0;
197 virtual RequestSetIfNotExist SetIfNotExist(std::string key, std::string value) = 0;
199 virtual RequestSetIfNotExist SetIfNotExist(std::string key, std::string value, std::chrono::milliseconds ttl) = 0;
201 virtual RequestSetex Setex(std::string key, std::chrono::seconds seconds, std::string value) = 0;
203 virtual RequestSismember Sismember(std::string key, std::string member) = 0;
205 virtual RequestSmembers Smembers(std::string key) = 0;
207 virtual RequestSrandmember Srandmember(std::string key) = 0;
209 virtual RequestSrandmembers Srandmembers(std::string key, int64_t count) = 0;
211 virtual RequestSrem Srem(std::string key, std::string member) = 0;
213 virtual RequestSrem Srem(std::string key, std::vector<std::string> members) = 0;
215 virtual RequestStrlen Strlen(std::string key) = 0;
217 virtual RequestTime Time(size_t shard) = 0;
219 virtual RequestTtl Ttl(std::string key) = 0;
221 virtual RequestType Type(std::string key) = 0;
223 virtual RequestZadd Zadd(std::string key,
double score, std::string member) = 0;
225 virtual RequestZadd Zadd(std::string key,
double score, std::string member,
const ZaddOptions& options) = 0;
227 virtual RequestZadd Zadd(std::string key, std::vector<std::pair<
double, std::string>> scored_members) = 0;
230 Zadd(std::string key, std::vector<std::pair<
double, std::string>> scored_members,
const ZaddOptions& options) = 0;
232 virtual RequestZaddIncr ZaddIncr(std::string key,
double score, std::string member) = 0;
234 virtual RequestZaddIncrExisting ZaddIncrExisting(std::string key,
double score, std::string member) = 0;
236 virtual RequestZcard Zcard(std::string key) = 0;
238 virtual RequestZcount Zcount(std::string key,
double min,
double max) = 0;
240 virtual RequestZrange Zrange(std::string key, int64_t start, int64_t stop) = 0;
242 virtual RequestZrangeWithScores ZrangeWithScores(std::string key, int64_t start, int64_t stop) = 0;
244 virtual RequestZrangebyscore Zrangebyscore(std::string key,
double min,
double max) = 0;
246 virtual RequestZrangebyscore Zrangebyscore(std::string key, std::string min, std::string max) = 0;
248 virtual RequestZrangebyscore
249 Zrangebyscore(std::string key,
double min,
double max,
const RangeOptions& range_options) = 0;
251 virtual RequestZrangebyscore
252 Zrangebyscore(std::string key, std::string min, std::string max,
const RangeOptions& range_options) = 0;
254 virtual RequestZrangebyscoreWithScores ZrangebyscoreWithScores(std::string key,
double min,
double max) = 0;
256 virtual RequestZrangebyscoreWithScores
257 ZrangebyscoreWithScores(std::string key, std::string min, std::string max) = 0;
259 virtual RequestZrangebyscoreWithScores
260 ZrangebyscoreWithScores(std::string key,
double min,
double max,
const RangeOptions& range_options) = 0;
262 virtual RequestZrangebyscoreWithScores
263 ZrangebyscoreWithScores(std::string key, std::string min, std::string max,
const RangeOptions& range_options) = 0;
265 virtual RequestZrem Zrem(std::string key, std::string member) = 0;
267 virtual RequestZrem Zrem(std::string key, std::vector<std::string> members) = 0;
269 virtual RequestZremrangebyrank Zremrangebyrank(std::string key, int64_t start, int64_t stop) = 0;
271 virtual RequestZremrangebyscore Zremrangebyscore(std::string key,
double min,
double max) = 0;
273 virtual RequestZremrangebyscore Zremrangebyscore(std::string key, std::string min, std::string max) = 0;
275 virtual RequestZscore Zscore(std::string key, std::string member) = 0;
284 using USERVER_NAMESPACE::redis::
Exception::Exception;
289 using USERVER_NAMESPACE::redis::
Exception::Exception;