userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
pttl_reply.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/storages/redis/pttl_reply.hpp
4
/// @brief Redis PTTL / HPTTL reply value (millisecond precision).
5
6
#
include
<
chrono
>
7
#
include
<
cstdint
>
8
#
include
<
string
>
9
10
#
include
<
userver
/
storages
/
redis
/
fwd
.
hpp
>
11
#
include
<
userver
/
storages
/
redis
/
ttl_reply
.
hpp
>
12
13
USERVER_NAMESPACE_BEGIN
14
15
namespace
storages::
redis
{
16
17
/// @brief Parsed PTTL / HPTTL reply (millisecond precision).
18
///
19
/// Sibling of @c TtlReply for the millisecond-precision variants of the TTL
20
/// commands. Reuses @c KeyHasNoExpirationException for its error case.
21
class
PttlReply
final
{
22
public
:
23
enum
class
PttlReplyValue : std::int8_t {
24
kKeyDoesNotExist = -2,
25
kKeyHasNoExpiration = -1,
26
};
27
28
static
constexpr
PttlReplyValue kKeyDoesNotExist = PttlReplyValue::kKeyDoesNotExist;
29
static
constexpr
PttlReplyValue kKeyHasNoExpiration = PttlReplyValue::kKeyHasNoExpiration;
30
31
explicit
PttlReply(int64_t value);
32
PttlReply(PttlReplyValue value);
33
34
/// @brief Parse a reply from a milliseconds-precision command (PTTL / HPTTL).
35
static
PttlReply
Parse
(ReplyData&& reply_data,
const
std::string& request_description = {});
36
37
bool
KeyExists()
const
;
38
bool
KeyHasExpiration()
const
;
39
40
/// @brief Returns the expiration as @c std::chrono::milliseconds. Throws
41
/// @c KeyHasNoExpirationException if the key/field has no expiration.
42
std::chrono::milliseconds
GetExpire
()
const
;
43
44
private
:
45
int64_t value_;
46
};
47
48
}
// namespace storages::redis
49
50
USERVER_NAMESPACE_END
userver
storages
redis
pttl_reply.hpp
Generated on
for userver by
Doxygen
1.17.0