9#include <userver/storages/redis/command_options.hpp>
10#include <userver/storages/redis/request.hpp>
12USERVER_NAMESPACE_BEGIN
30 enum class CheckShards { kNo, kSame };
32 virtual ~Transaction() =
default;
40 virtual RequestExec
Exec(
const CommandControl& command_control) = 0;
44 virtual RequestAppend Append(std::string key, std::string value) = 0;
46 virtual RequestDbsize Dbsize(size_t shard) = 0;
48 virtual RequestDel Del(std::string key) = 0;
50 virtual RequestDel Del(std::vector<std::string> keys) = 0;
52 virtual RequestUnlink Unlink(std::string key) = 0;
54 virtual RequestUnlink Unlink(std::vector<std::string> keys) = 0;
56 virtual RequestExists Exists(std::string key) = 0;
58 virtual RequestExists Exists(std::vector<std::string> keys) = 0;
60 virtual RequestExpire Expire(std::string key, std::chrono::seconds ttl) = 0;
62 virtual RequestGeoadd Geoadd(std::string key, GeoaddArg point_member) = 0;
64 virtual RequestGeoadd Geoadd(std::string key,
65 std::vector<GeoaddArg> point_members) = 0;
67 virtual RequestGeoradius Georadius(
68 std::string key, Longitude lon, Latitude lat,
double radius,
69 const GeoradiusOptions& georadius_options) = 0;
71 virtual RequestGeosearch Geosearch(
72 std::string key, std::string member,
double radius,
73 const GeosearchOptions& geosearch_options) = 0;
75 virtual RequestGeosearch Geosearch(
76 std::string key, std::string member, BoxWidth width, BoxHeight height,
77 const GeosearchOptions& geosearch_options) = 0;
79 virtual RequestGeosearch Geosearch(
80 std::string key, Longitude lon, Latitude lat,
double radius,
81 const GeosearchOptions& geosearch_options) = 0;
83 virtual RequestGeosearch Geosearch(
84 std::string key, Longitude lon, Latitude lat, BoxWidth width,
85 BoxHeight height,
const GeosearchOptions& geosearch_options) = 0;
87 virtual RequestGet Get(std::string key) = 0;
89 virtual RequestGetset Getset(std::string key, std::string value) = 0;
91 virtual RequestHdel Hdel(std::string key, std::string field) = 0;
93 virtual RequestHdel Hdel(std::string key,
94 std::vector<std::string> fields) = 0;
96 virtual RequestHexists Hexists(std::string key, std::string field) = 0;
98 virtual RequestHget Hget(std::string key, std::string field) = 0;
100 virtual RequestHgetall Hgetall(std::string key) = 0;
102 virtual RequestHincrby Hincrby(std::string key, std::string field,
103 int64_t increment) = 0;
105 virtual RequestHincrbyfloat Hincrbyfloat(std::string key, std::string field,
106 double increment) = 0;
108 virtual RequestHkeys Hkeys(std::string key) = 0;
110 virtual RequestHlen Hlen(std::string key) = 0;
112 virtual RequestHmget Hmget(std::string key,
113 std::vector<std::string> fields) = 0;
115 virtual RequestHmset Hmset(
117 std::vector<std::pair<std::string, std::string>> field_values) = 0;
119 virtual RequestHset Hset(std::string key, std::string field,
120 std::string value) = 0;
122 virtual RequestHsetnx Hsetnx(std::string key, std::string field,
123 std::string value) = 0;
125 virtual RequestHvals Hvals(std::string key) = 0;
127 virtual RequestIncr Incr(std::string key) = 0;
129 virtual RequestKeys Keys(std::string keys_pattern, size_t shard) = 0;
131 virtual RequestLindex Lindex(std::string key, int64_t index) = 0;
133 virtual RequestLlen Llen(std::string key) = 0;
135 virtual RequestLpop Lpop(std::string key) = 0;
137 virtual RequestLpush Lpush(std::string key, std::string value) = 0;
139 virtual RequestLpush Lpush(std::string key,
140 std::vector<std::string> values) = 0;
142 virtual RequestLpushx Lpushx(std::string key, std::string element) = 0;
144 virtual RequestLrange Lrange(std::string key, int64_t start,
147 virtual RequestLrem Lrem(std::string key, int64_t count,
148 std::string element) = 0;
150 virtual RequestLtrim Ltrim(std::string key, int64_t start, int64_t stop) = 0;
152 virtual RequestMget Mget(std::vector<std::string> keys) = 0;
154 virtual RequestMset Mset(
155 std::vector<std::pair<std::string, std::string>> key_values) = 0;
157 virtual RequestPersist Persist(std::string key) = 0;
159 virtual RequestPexpire Pexpire(std::string key,
160 std::chrono::milliseconds ttl) = 0;
162 virtual RequestPing Ping(size_t shard) = 0;
164 virtual RequestPingMessage PingMessage(size_t shard, std::string message) = 0;
166 virtual RequestRename Rename(std::string key, std::string new_key) = 0;
168 virtual RequestRpop Rpop(std::string key) = 0;
170 virtual RequestRpush Rpush(std::string key, std::string value) = 0;
172 virtual RequestRpush Rpush(std::string key,
173 std::vector<std::string> values) = 0;
175 virtual RequestRpushx Rpushx(std::string key, std::string element) = 0;
177 virtual RequestSadd Sadd(std::string key, std::string member) = 0;
179 virtual RequestSadd Sadd(std::string key,
180 std::vector<std::string> members) = 0;
182 virtual RequestScard Scard(std::string key) = 0;
184 virtual RequestSet Set(std::string key, std::string value) = 0;
186 virtual RequestSet Set(std::string key, std::string value,
187 std::chrono::milliseconds ttl) = 0;
189 virtual RequestSetIfExist SetIfExist(std::string key, std::string value) = 0;
191 virtual RequestSetIfExist SetIfExist(std::string key, std::string value,
192 std::chrono::milliseconds ttl) = 0;
194 virtual RequestSetIfNotExist SetIfNotExist(std::string key,
195 std::string value) = 0;
197 virtual RequestSetIfNotExist SetIfNotExist(std::string key, std::string value,
198 std::chrono::milliseconds ttl) = 0;
200 virtual RequestSetex Setex(std::string key, std::chrono::seconds seconds,
201 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,
214 std::vector<std::string> members) = 0;
216 virtual RequestStrlen Strlen(std::string key) = 0;
218 virtual RequestTime Time(size_t shard) = 0;
220 virtual RequestTtl Ttl(std::string key) = 0;
222 virtual RequestType Type(std::string key) = 0;
224 virtual RequestZadd Zadd(std::string key,
double score,
225 std::string member) = 0;
227 virtual RequestZadd Zadd(std::string key,
double score, std::string member,
228 const ZaddOptions& options) = 0;
230 virtual RequestZadd Zadd(
232 std::vector<std::pair<
double, std::string>> scored_members) = 0;
234 virtual RequestZadd Zadd(
236 std::vector<std::pair<
double, std::string>> scored_members,
237 const ZaddOptions& options) = 0;
239 virtual RequestZaddIncr ZaddIncr(std::string key,
double score,
240 std::string member) = 0;
242 virtual RequestZaddIncrExisting ZaddIncrExisting(std::string key,
244 std::string member) = 0;
246 virtual RequestZcard Zcard(std::string key) = 0;
248 virtual RequestZcount Zcount(std::string key,
double min,
double max) = 0;
250 virtual RequestZrange Zrange(std::string key, int64_t start,
253 virtual RequestZrangeWithScores ZrangeWithScores(std::string key,
257 virtual RequestZrangebyscore Zrangebyscore(std::string key,
double min,
260 virtual RequestZrangebyscore Zrangebyscore(std::string key, std::string min,
261 std::string max) = 0;
263 virtual RequestZrangebyscore Zrangebyscore(
264 std::string key,
double min,
double max,
265 const RangeOptions& range_options) = 0;
267 virtual RequestZrangebyscore Zrangebyscore(
268 std::string key, std::string min, std::string max,
269 const RangeOptions& range_options) = 0;
271 virtual RequestZrangebyscoreWithScores ZrangebyscoreWithScores(
272 std::string key,
double min,
double max) = 0;
274 virtual RequestZrangebyscoreWithScores ZrangebyscoreWithScores(
275 std::string key, std::string min, std::string max) = 0;
277 virtual RequestZrangebyscoreWithScores ZrangebyscoreWithScores(
278 std::string key,
double min,
double max,
279 const RangeOptions& range_options) = 0;
281 virtual RequestZrangebyscoreWithScores ZrangebyscoreWithScores(
282 std::string key, std::string min, std::string max,
283 const RangeOptions& range_options) = 0;
285 virtual RequestZrem Zrem(std::string key, std::string member) = 0;
287 virtual RequestZrem Zrem(std::string key,
288 std::vector<std::string> members) = 0;
290 virtual RequestZremrangebyrank Zremrangebyrank(std::string key, int64_t start,
293 virtual RequestZremrangebyscore Zremrangebyscore(std::string key,
double min,
296 virtual RequestZremrangebyscore Zremrangebyscore(std::string key,
298 std::string max) = 0;
300 virtual RequestZscore Zscore(std::string key, std::string member) = 0;
309 using USERVER_NAMESPACE::redis::
Exception::Exception;
313 :
public USERVER_NAMESPACE::redis::
Exception {
315 using USERVER_NAMESPACE::redis::
Exception::Exception;