acl/lib_acl_cpp/include/acl_cpp/redis/redis_cluster.hpp

65 lines
1.5 KiB
C++
Raw Normal View History

#pragma once
#include "acl_cpp/acl_cpp_define.hpp"
#include <vector>
#include "acl_cpp/stdlib/string.hpp"
#include "acl_cpp/connpool/connect_manager.hpp"
namespace acl
{
class redis_pool;
class ACL_CPP_API redis_cluster : public connect_manager
{
public:
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param conn_timeout {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD>ʱʱ<EFBFBD><EFBFBD>(<EFBFBD><EFBFBD>)
* @param rw_timeout {int}<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> IO <EFBFBD><EFBFBD>д<EFBFBD><EFBFBD>ʱʱ<EFBFBD><EFBFBD>(<EFBFBD><EFBFBD>)
* @param max_slot {int} <EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
*/
redis_cluster(int conn_timeout, int rw_timeout, int max_slot = 16384);
virtual ~redis_cluster();
/**
* <EFBFBD><EFBFBD><EFBFBD>ݹ<EFBFBD>ϣ<EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD>
* @param slot {int} <EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD>ֵ
* @return {redis_pool*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>Ĺ<EFBFBD>ϣ<EFBFBD>۲<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>򷵻<EFBFBD> NULL
*/
redis_pool* peek_slot(int slot);
/**
* <EFBFBD><EFBFBD><EFBFBD>ù<EFBFBD>ϣ<EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD> redis <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
* @param slot {int} <EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD>ֵ
* @param addr {const char*} redis <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
*/
void set_slot(int slot, const char* addr);
/**
* <EFBFBD><EFBFBD><EFBFBD>ù<EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
* @return {int}
*/
int get_max_slot() const
{
return max_slot_;
}
protected:
/**
* <EFBFBD><EFBFBD><EFBFBD>ി<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳض<EFBFBD><EFBFBD><EFBFBD>
* @param addr {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>ip:port
* @param count {int} <EFBFBD><EFBFBD><EFBFBD>ӳصĴ<EFBFBD>С<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param idx {size_t} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳض<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD>±<EFBFBD>λ<EFBFBD><EFBFBD>(<EFBFBD><EFBFBD> 0 <EFBFBD><EFBFBD>ʼ)
*/
virtual acl::connect_pool* create_pool(const char* addr,
int count, size_t idx);
private:
int conn_timeout_;
int rw_timeout_;
int max_slot_;
const char** slot_addrs_;
std::vector<char*> addrs_;
};
} // namespace acl