-
Notifications
You must be signed in to change notification settings - Fork 952
Expand file tree
/
Copy pathredis_slot.hpp
More file actions
93 lines (78 loc) · 2.04 KB
/
redis_slot.hpp
File metadata and controls
93 lines (78 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#pragma once
#include "../acl_cpp_define.hpp"
#include <vector>
#if !defined(ACL_CLIENT_ONLY) && !defined(ACL_REDIS_DISABLE)
namespace acl {
class ACL_CPP_API redis_slot {
public:
/**
* Constructor
* constructor
* @param slot_min {size_t} Minimum hash slot value
* the min hash-slot
* @param slot_max {size_t} Maximum hash slot value
* the max hash-slot
* @param ip {const char*} IP address of the current redis-server
* the given redis-server's ip
* @param port {int} Listening port of the current redis-server
* the listening port of the given redis-server
*/
redis_slot(size_t slot_min, size_t slot_max, const char* ip, int port);
redis_slot(const redis_slot& node);
~redis_slot();
/**
* Add a redis hash slot slave node to the current node
* add a slave slot node to the current node
* @param node {redis_slot*} A slave node storing hash slots
* the slave slot node
*/
redis_slot& add_slave(redis_slot* node);
/**
* Get all slave nodes of the current hash slot node
* get the slave nodes of the current node
* @return {const std::vector<redis_slot*>&}
*/
const std::vector<redis_slot*>& get_slaves() const {
return slaves_;
}
/**
* Get the IP address of the current node
* get the ip of the current node
* @return {const char*}
*/
const char* get_ip() const {
return ip_;
}
/**
* Get the port number of the current node
* get the port of the current node
* @return {int}
*/
int get_port() const {
return port_;
}
/**
* Get the minimum value of the current hash slot node
* get the min hash slot of the current node
* @return {size_t}
*/
size_t get_slot_min() const {
return slot_min_;
}
/**
* Get the maximum value of the current hash slot node
* get the max hash slot of the current node
* @return {size_t}
*/
size_t get_slot_max() const {
return slot_max_;
}
private:
size_t slot_min_;
size_t slot_max_;
char ip_[128];
int port_;
std::vector<redis_slot*> slaves_;
};
} // namespace acl
#endif // !defined(ACL_CLIENT_ONLY) && !defined(ACL_REDIS_DISABLE)