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

89 lines
2.3 KiB
C++
Raw Normal View History

#pragma once
#include "acl_cpp/acl_cpp_define.hpp"
#include <vector>
#include <list>
#include "acl_cpp/stdlib/string.hpp"
#include "acl_cpp/redis/redis_node.hpp"
#include "acl_cpp/redis/redis_command.hpp"
namespace acl
{
class redis_result;
class ACL_CPP_API redis_cluster : virtual public redis_command
{
public:
/**
* see redis_command::redis_command()
*/
redis_cluster();
/**
* see redis_command::redis_command(redis_client*)
*/
redis_cluster(redis_client* conn);
/**
* see redis_command::redis_command(redis_client_cluster*<EFBFBD><EFBFBD> size_t)
*/
redis_cluster(redis_client_cluster* cluster, size_t max_conns);
virtual ~redis_cluster();
2015-03-01 23:50:53 +08:00
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD><EFBFBD>õĹ<EFBFBD>ϣ<EFBFBD>ۣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><EFBFBD> 0 <EFBFBD>Ĺ<EFBFBD>ϣ<EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* add some hash-slots, the last slot value must be < 0
* @param first {int} <EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD>ۣ<EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> >= 0 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч
* the first hash-slot which must be >= 0
* @return {bool} <EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD>
* return true if success
*/
bool addslots(int first, ...);
bool addslots(const int slot_list[], size_t n);
bool addslots(const std::vector<int>& slot_list);
bool delslots(int first, ...);
bool delslots(const int slot_list[], size_t n);
bool delslots(const std::vector<int>& slot_list);
2015-03-01 23:50:53 +08:00
int getkeysinslot(size_t slot, size_t max, std::list<string>& result);
2015-03-01 23:50:53 +08:00
bool meet(const char* ip, int port);
bool reset();
bool reset_hard();
bool reset_soft();
2015-03-01 23:50:53 +08:00
bool setslot_importing(size_t slot, const char* src_node);
bool setslot_migrating(size_t slot, const char* dst_node);
bool setslot_stable(size_t slot);
bool setslot_node(size_t slot, const char* node);
int count_failure_reports(const char* node);
bool failover();
bool failover_force();
bool failover_takeover();
bool info(string& result);
bool nodes(string& result);
bool saveconfig();
bool slaves(const char* node, std::vector<string>& result);
int countkeysinslot(size_t slot);
bool forget(const char* node);
int keyslot(const char* key);
bool replicate(const char* node);
bool set_config_epoch(const char* epoch);
const std::vector<redis_node*>* slots();
2015-03-01 23:50:53 +08:00
private:
std::vector<redis_node*> nodes_;
redis_node* get_master_node(const redis_result* rr);
redis_node* create_node(const redis_result* rr,
size_t slot_max, size_t slot_min);
void free_nodes();
};
} // namespace acl