userver: userver/storages/redis/impl/reply/ttl_reply.hpp Source File
⚠️ This is the documentation for an old userver version. Click here to switch to the latest version.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
ttl_reply.hpp
1#pragma once
2
3#include <cstdint>
4#include <string>
5
6#include <userver/storages/redis/impl/exception.hpp>
7#include <userver/storages/redis/impl/types.hpp>
8
9USERVER_NAMESPACE_BEGIN
10
11namespace redis {
12
13class TtlReply final {
14 public:
15 enum class TtlReplyValue { kKeyDoesNotExist = -2, kKeyHasNoExpiration = -1 };
16
17 static constexpr TtlReplyValue kKeyDoesNotExist =
18 TtlReplyValue::kKeyDoesNotExist;
19 static constexpr TtlReplyValue kKeyHasNoExpiration =
20 TtlReplyValue::kKeyHasNoExpiration;
21
22 explicit TtlReply(int64_t value);
23 TtlReply(TtlReplyValue value);
24
25 static TtlReply Parse(ReplyData&& reply_data,
26 const std::string& request_description = {});
27
28 bool KeyExists() const;
29 bool KeyHasExpiration() const;
30 size_t GetExpireSeconds() const;
31
32 private:
33 int64_t value_;
34};
35
36/// Trying to get expiration from a nonexistent or a persistent key
38 public:
39 using Exception::Exception;
40};
41
42} // namespace redis
43
44USERVER_NAMESPACE_END