userver: userver/storages/redis/ttl_reply.hpp Source File
Loading...
Searching...
No Matches
ttl_reply.hpp
Go to the documentation of this file.
1#pragma once
2
5
6#include <chrono>
7#include <cstdint>
8#include <string>
9
12
13USERVER_NAMESPACE_BEGIN
14
15namespace storages::redis {
16
25class TtlReply final {
26public:
27 enum class TtlReplyValue { kKeyDoesNotExist = -2, kKeyHasNoExpiration = -1 };
28
29 static constexpr TtlReplyValue kKeyDoesNotExist = TtlReplyValue::kKeyDoesNotExist;
30 static constexpr TtlReplyValue kKeyHasNoExpiration = TtlReplyValue::kKeyHasNoExpiration;
31
32 explicit TtlReply(int64_t value);
33 TtlReply(TtlReplyValue value);
34
35 static TtlReply Parse(ReplyData&& reply_data, const std::string& request_description = {});
36
37 bool KeyExists() const;
38 bool KeyHasExpiration() const;
39 [[deprecated("Use GetExpire() instead")]] size_t GetExpireSeconds() const { return GetExpire().count(); }
40
43 std::chrono::seconds GetExpire() const;
44
45private:
46 int64_t value_;
47};
48
51public:
52 using Exception::Exception;
53};
54
55} // namespace storages::redis
56
57USERVER_NAMESPACE_END