acl/lib_acl_cpp/include/acl_cpp/redis/redis_pool.hpp
2015-01-16 01:08:31 -08:00

41 lines
951 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
#include "acl_cpp/acl_cpp_define.hpp"
#include "acl_cpp/connpool/connect_pool.hpp"
namespace acl
{
class ACL_CPP_API redis_pool : public connect_pool
{
public:
/**
* 构造函数
* @param addr {const char*} 服务端地址格式ip:port
* @param count {int} 连接池的最大连接数限制
* @param idx {size_t} 该连接池对象在集合中的下标位置(从 0 开始)
*/
redis_pool(const char* addr, int count, size_t idx = 0);
virtual ~redis_pool();
/**
* 设置网络连接超时时间及网络 IO 读写超时时间(秒)
* @param conn_timeout {int} 连接超时时间
* @param rw_timeout {int} 网络 IO 读写超时时间(秒)
* @return {redis_pool&}
*/
redis_pool& set_timeout(int conn_timeout, int rw_timeout);
protected:
/**
* 基类纯虚函数: 调用此函数用来创建一个新的连接
* @return {connect_client*}
*/
virtual connect_client* create_connect();
private:
int conn_timeout_;
int rw_timeout_;
};
} // namespace acl