userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
reply_types.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file
4
/// @brief Definitions of structures representing different Redis replies.
5
6
#
include
<
string
>
7
#
include
<
vector
>
8
9
#
include
<
userver
/
storages
/
redis
/
base
.
hpp
>
10
#
include
<
userver
/
storages
/
redis
/
expire_reply
.
hpp
>
11
#
include
<
userver
/
storages
/
redis
/
ttl_reply
.
hpp
>
12
13
#
include
<
userver
/
storages
/
redis
/
key_type
.
hpp
>
14
#
include
<
userver
/
storages
/
redis
/
reply_fwd
.
hpp
>
15
#
include
<
userver
/
storages
/
redis
/
scan_tag
.
hpp
>
16
17
USERVER_NAMESPACE_BEGIN
18
19
namespace
storages::
redis
{
20
21
enum
class
HsetReply { kCreated, kUpdated };
22
23
/// @brief Result of HSETEX.
24
enum
class
HsetexReply
:
std
::
int8_t
{
25
kConditionNotMet
= 0,
///< FNX/FXX condition failed; no fields written
26
kFieldsSet
= 1,
///< Fields written
27
};
28
29
struct
Point
{
30
double
lon;
31
double
lat;
32
33
bool
operator==(
const
Point
& rhs)
const
{
return
std::tie(lon, lat) == std::tie(rhs.lon, rhs.lat); }
34
};
35
36
struct
GeoPoint
final
{
37
std::string member;
38
std::optional<
double
> dist;
39
std::optional<uint64_t> hash;
40
std::optional<
Point
> point;
41
42
GeoPoint() =
default
;
43
44
GeoPoint(std::string member, std::optional<
double
> dist, std::optional<uint64_t> hash, std::optional<
Point
> point)
45
: member(std::move(member)),
46
dist(dist),
47
hash(hash),
48
point(point)
49
{}
50
51
bool
operator==(
const
GeoPoint& rhs)
const
{
52
return
std::tie(member, dist, hash, point) == std::tie(rhs.member, rhs.dist, rhs.hash, rhs.point);
53
}
54
};
55
56
/// @brief Data type that holds `member` and `score`.
57
///
58
/// Sample usage:
59
/// @snippet redis/src/storages/redis/client_scan_redistest.cpp Sample Zscan usage
60
struct
MemberScore
final
{
61
std::string member;
62
double
score{0.0};
63
64
MemberScore() =
default
;
65
MemberScore(std::string member,
double
score)
66
: member(std::move(member)),
67
score(score)
68
{}
69
70
operator std::pair<std::string,
double
>()
const
& {
return
{member, score}; }
71
72
operator std::pair<std::string,
double
>() && {
return
{std::move(member), score}; }
73
74
operator std::pair<
const
std::string,
double
>()
const
& {
return
{member, score}; }
75
76
operator std::pair<
const
std::string,
double
>() && {
return
{std::move(member), score}; }
77
78
bool
operator==(
const
MemberScore& rhs)
const
{
return
member == rhs.member && score == rhs.score; }
79
};
80
81
enum
class
PersistReply { kKeyOrTimeoutNotFound, kTimeoutRemoved };
82
83
/// @brief Per-field result of HEXPIRE / HPEXPIRE / HEXPIREAT / HPEXPIREAT.
84
enum
class
HexpireReply
:
std
::
int8_t
{
85
kFieldDoesNotExist = -2,
86
kConditionNotMet
= 0,
///< NX/XX/GT/LT predicate failed
87
kExpirationUpdated
= 1,
///< TTL applied
88
kFieldDeleted
= 2,
///< ttl <= 0 / already in the past — field removed
89
};
90
91
/// @brief Per-field result of HPERSIST.
92
enum
class
HpersistReply
:
std
::
int8_t
{
93
kFieldDoesNotExist = -2,
94
kFieldHasNoExpiration = -1,
95
kExpirationRemoved = 1,
96
};
97
98
template
<
ScanTag
>
99
struct
ScanReplyElem
;
100
101
template
<>
102
struct
ScanReplyElem
<
ScanTag
::
kScan
> {
103
using
type = std::string;
104
};
105
106
template
<>
107
struct
ScanReplyElem
<
ScanTag
::
kSscan
> {
108
using
type = std::string;
109
};
110
111
template
<>
112
struct
ScanReplyElem
<
ScanTag
::
kHscan
> {
113
using
type = std::pair<std::string, std::string>;
114
};
115
116
template
<>
117
struct
ScanReplyElem
<
ScanTag
::
kZscan
> {
118
using
type = MemberScore;
119
};
120
121
enum
class
SetReply { kSet, kNotSet };
122
123
enum
class
StatusOk { kOk };
124
125
enum
class
StatusPong { kPong };
126
127
}
// namespace storages::redis
128
129
USERVER_NAMESPACE_END
userver
storages
redis
reply_types.hpp
Generated on
for userver by
Doxygen
1.17.0