userver: userver/storages/redis/impl/keyshard.hpp Source File
Loading...
Searching...
No Matches
keyshard.hpp
1#pragma once
2
3#include <memory>
4#include <string>
5
6USERVER_NAMESPACE_BEGIN
7
8namespace redis {
9
10void GetRedisKey(const std::string& key, size_t* key_start, size_t* key_len);
11
12class KeyShard {
13 public:
14 virtual ~KeyShard() = default;
15 virtual size_t ShardByKey(const std::string& key) const = 0;
16 virtual bool IsGenerateKeysForShardsEnabled() const = 0;
17};
18
19class KeyShardFactory {
20 std::string type_;
21
22 public:
23 KeyShardFactory(const std::string& type) : type_(type) {}
24 std::unique_ptr<redis::KeyShard> operator()(size_t nshards);
25};
26
27enum class PubShard {
28 kZeroShard,
29 kRoundRobin,
30};
31
32} // namespace redis
33
34USERVER_NAMESPACE_END