userver: userver/storages/redis/reply_types.hpp Source File
Loading...
Searching...
No Matches
reply_types.hpp
Go to the documentation of this file.
1#pragma once
2
5
6#include <string>
7#include <vector>
8
12
16
17USERVER_NAMESPACE_BEGIN
18
19namespace storages::redis {
20
21enum class HsetReply { kCreated, kUpdated };
22
24enum class HsetexReply : std::int8_t {
27};
28
30enum class MsetexReply : std::int8_t {
33};
34
35struct Point {
36 double lon;
37 double lat;
38
39 bool operator==(const Point& rhs) const { return std::tie(lon, lat) == std::tie(rhs.lon, rhs.lat); }
40};
41
42struct GeoPoint final {
43 std::string member;
44 std::optional<double> dist;
45 std::optional<uint64_t> hash;
46 std::optional<Point> point;
47
48 GeoPoint() = default;
49
50 GeoPoint(std::string member, std::optional<double> dist, std::optional<uint64_t> hash, std::optional<Point> point)
51 : member(std::move(member)),
52 dist(dist),
53 hash(hash),
54 point(point)
55 {}
56
57 bool operator==(const GeoPoint& rhs) const {
58 return std::tie(member, dist, hash, point) == std::tie(rhs.member, rhs.dist, rhs.hash, rhs.point);
59 }
60};
61
66struct MemberScore final {
67 std::string member;
68 double score{0.0};
69
70 MemberScore() = default;
71 MemberScore(std::string member, double score)
72 : member(std::move(member)),
73 score(score)
74 {}
75
76 operator std::pair<std::string, double>() const& { return {member, score}; }
77
78 operator std::pair<std::string, double>() && { return {std::move(member), score}; }
79
80 operator std::pair<const std::string, double>() const& { return {member, score}; }
81
82 operator std::pair<const std::string, double>() && { return {std::move(member), score}; }
83
84 bool operator==(const MemberScore& rhs) const { return member == rhs.member && score == rhs.score; }
85};
86
87enum class PersistReply { kKeyOrTimeoutNotFound, kTimeoutRemoved };
88
90enum class HexpireReply : std::int8_t {
91 kFieldDoesNotExist = -2,
95};
96
98enum class HpersistReply : std::int8_t {
99 kFieldDoesNotExist = -2,
100 kFieldHasNoExpiration = -1,
101 kExpirationRemoved = 1,
102};
103
104template <ScanTag>
106
107template <>
109 using type = std::string;
110};
111
112template <>
114 using type = std::string;
115};
116
117template <>
119 using type = std::pair<std::string, std::string>;
120};
121
122template <>
124 using type = MemberScore;
125};
126
127enum class SetReply { kSet, kNotSet };
128
129enum class StatusOk { kOk };
130
131enum class StatusPong { kPong };
132
133} // namespace storages::redis
134
135USERVER_NAMESPACE_END