forked from acl-dev/acl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathredis_client_pool.hpp
55 lines (48 loc) · 1.57 KB
/
redis_client_pool.hpp
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
#pragma once
#include "acl_cpp/acl_cpp_define.hpp"
#include "acl_cpp/connpool/connect_pool.hpp"
namespace acl
{
/**
* redis 连接池类,该类继承于 connect_pool,在 connect_pool 定义了通用的有关
* TCP 连接池的通用方法。
* redis connection pool inherting from connect_pool, which includes
* TCP connection pool methods.
*/
class ACL_CPP_API redis_client_pool : public connect_pool
{
public:
/**
* 构造函数
* constructor
* @param addr {const char*} 服务端地址,格式:ip:port
* the redis-server's listening address, format: ip:port
* @param count {int} 连接池的最大连接数限制
* the max connections for each connection pool
* @param idx {size_t} 该连接池对象在集合中的下标位置(从 0 开始)
* the subscript of the connection pool in the connection cluster
*/
redis_client_pool(const char* addr, int count, size_t idx = 0);
virtual ~redis_client_pool();
/**
* 设置网络连接超时时间及网络 IO 读写超时时间(秒)
* set the connect and read/write timeout in seconds
* @param conn_timeout {int} 连接超时时间
* the timeout to connect in seconds
* @param rw_timeout {int} 网络 IO 读写超时时间(秒)
* the timeout to read/write in seconds
* @return {redis_client_pool&}
*/
redis_client_pool& set_timeout(int conn_timeout, int rw_timeout);
protected:
/**
* 基类纯虚函数: 调用此函数用来创建一个新的连接
* virtual function in class connect_pool to create a new connection
* @return {connect_client*}
*/
virtual connect_client* create_connect();
private:
int conn_timeout_;
int rw_timeout_;
};
} // namespace acl