rewrite redis modules in order to support redis3.0 cluster in future

This commit is contained in:
ubuntu14 2015-02-13 06:52:43 -08:00
parent be6e546eae
commit 8bc89f7dbc
23 changed files with 1889 additions and 1910 deletions

View File

@ -1,6 +1,10 @@
修改历史列表:
------------------------------------------------------------------------
284) 2015.2.13
284.1) workaround: 对 redis 模块进行重构,以便于更好地支持 redis3.0 中的
集群模式
283) 2015.2.11
283.1) samples: 因为 acl_master 模式运行的服务器框架不支持 WIN32所以现在
将所有 master_xxx 系列的示例在 WIN32 下强制采用 alone 运行模式

View File

@ -19,149 +19,43 @@ public:
int rw_timeout = 30, bool retry = true);
~redis_client();
void set_slice_request(bool on);
void set_slice_respond(bool on);
dbuf_pool* get_pool() const
{
return pool_;
}
bool eof() const;
void close();
socket_stream* get_stream();
void reset();
void close();
void reset_request();
void set_slice_request(bool on);
void set_slice_respond(bool on);
const redis_result* get_result() const
{
return result_;
}
const redis_result* run(size_t nchildren = 0);
int get_number(bool* success = NULL);
long long int get_number64(bool* success = NULL);
int get_number(std::vector<int>& out);
int get_number64(std::vector<long long int>& out);
bool get_status(const char* success = "OK");
int get_status(std::vector<bool>& out);
const char* get_status_string();
int get_string(string& buf);
int get_string(string* buf);
int get_string(char* buf, size_t size);
int get_strings(std::vector<string>& result);
int get_strings(std::vector<string>* result);
int get_strings(std::map<string, string>& result);
int get_strings(std::vector<string>& names,
std::vector<string>& values);
int get_strings(std::vector<const char*>& names,
std::vector<const char*>& values);
const char* get_value(size_t i, size_t* len = NULL);
const redis_result* get_child(size_t i) const;
size_t get_size() const;
/*******************************************************************/
void build_request(size_t argc, const char* argv[], size_t lens[]);
/*******************************************************************/
void build(const char* cmd, const char* key,
const std::map<string, string>& attrs);
void build(const char* cmd, const char* key,
const std::map<string, const char*>& attrs);
void build(const char* cmd, const char* key,
const std::map<int, string>& attrs);
void build(const char* cmd, const char* key,
const std::map<int, const char*>& attrs);
void build(const char* cmd, const char* key,
const std::vector<string>& names,
const std::vector<string>& values);
void build(const char* cmd, const char* key,
const std::vector<const char*>& names,
const std::vector<const char*>& values);
void build(const char* cmd, const char* key,
const std::vector<int>& names,
const std::vector<string>& values);
void build(const char* cmd, const char* key,
const std::vector<int>& names,
const std::vector<const char*>& values);
void build(const char* cmd, const char* key,
const char* names[], const char* values[], size_t argc);
void build(const char* cmd, const char* key,
const int names[], const char* values[], size_t argc);
void build(const char* cmd, const char* key,
const char* names[], const size_t names_len[],
const char* values[], const size_t values_len[], size_t argc);
/*******************************************************************/
void build(const char* cmd, const char* key,
const std::vector<string>& names);
void build(const char* cmd, const char* key,
const std::vector<const char*>& names);
void build(const char* cmd, const char* key,
const std::vector<int>& names);
void build(const char* cmd, const char* key,
const char* names[], size_t argc);
void build(const char* cmd, const char* key,
const int names[], size_t argc);
void build(const char* cmd, const char* key,
const char* names[], const size_t lens[], size_t argc);
/*******************************************************************/
const redis_result* run(dbuf_pool* pool, const string& req,
size_t nchildren);
const redis_result* run(dbuf_pool* pool, const redis_request& req,
size_t nchildren);
protected:
// 基类虚函数
virtual bool open();
private:
bool slice_req_;
bool slice_res_;
unsigned long long used_;
dbuf_pool* pool_;
socket_stream conn_;
char* addr_;
int conn_timeout_;
int rw_timeout_;
bool retry_;
size_t argv_size_;
const char** argv_;
size_t* argv_lens_;
size_t argc_;
string request_;
string buf_;
redis_request* req_;
redis_result* result_;
bool slice_req_;
bool slice_res_;
void argv_space(size_t n);
redis_result* get_redis_objects(dbuf_pool* pool, size_t nobjs);
redis_result* get_redis_object(dbuf_pool* pool);
redis_result* get_redis_error(dbuf_pool* pool);
redis_result* get_redis_status(dbuf_pool* pool);
redis_result* get_redis_integer(dbuf_pool* pool);
redis_result* get_redis_string(dbuf_pool* pool);
redis_result* get_redis_array(dbuf_pool* pool);
redis_result* get_redis_objects(size_t nobjs);
redis_result* get_redis_object();
redis_result* get_redis_error();
redis_result* get_redis_status();
redis_result* get_redis_integer();
redis_result* get_redis_string();
redis_result* get_redis_array();
void put_data(redis_result* rr, const char* data, size_t len);
void build_request1(size_t argc, const char* argv[], size_t lens[]);
void build_request2(size_t argc, const char* argv[], size_t lens[]);
const redis_result* run1(size_t nchildren);
const redis_result* run2(size_t nchildren);
void put_data(dbuf_pool* pool, redis_result* rr,
const char* data, size_t len);
};
} // end namespace acl

View File

@ -38,23 +38,32 @@ public:
return conn_;
}
/**
* redis_command
* @return {dbuf_pool*}
*/
dbuf_pool* get_pool() const
{
return pool_;
}
/**
*
* @return {redis_result_t}
*/
redis_result_t get_type() const;
redis_result_t result_type() const;
/**
* REDIS_RESULT_STATUS
* @return {const char*} ""
*/
const char* get_status() const;
const char* result_status() const;
/**
* REDIS_RESULT_ERROR
* @return {const char*} ""
*/
const char* get_error() const;
const char* result_error() const;
/**
* ,
@ -66,21 +75,21 @@ public:
* REDIS_RESULT_STRING: > 0
* REDIS_RESULT_ARRAY: children_->size()
*/
size_t get_size() const;
size_t result_size() const;
/**
* REDIS_RESULT_INTEGER 32
* @param success {bool*} NULL
* @return {int}
*/
int get_integer(bool* success = NULL) const;
int result_number(bool* success = NULL) const;
/**
* REDIS_RESULT_INTEGER 64
* @param success {bool*} NULL
* @return {long long int}
*/
long long int get_integer64(bool* success = NULL) const;
long long int result_number64(bool* success = NULL) const;
/**
* ( REDIS_RESULT_ARRAY
@ -88,7 +97,7 @@ public:
* @param len {size_t*} NULL
* @return {const char*} NULL
*/
const char* get(size_t i, size_t* len = NULL) const;
const char* get_result(size_t i, size_t* len = NULL) const;
/**
* redis (redis_client)
@ -109,7 +118,7 @@ public:
* @return {const redis_result*}
* NULL
*/
const redis_result* get_child(size_t i) const;
const redis_result* result_child(size_t i) const;
/**
* redis-server
@ -122,14 +131,128 @@ public:
*
* len
*/
const char* get_value(size_t i, size_t* len = NULL) const;
const char* result_value(size_t i, size_t* len = NULL) const;
/////////////////////////////////////////////////////////////////////
/**
* true
*
* @param on {bool} false
*/
void set_slice_request(bool on);
/**
* true
*
* @param on {bool} false
*/
void set_slice_respond(bool on);
protected:
redis_client* conn_;
const redis_result* run(size_t nchildren = 0);
void build_request(size_t argc, const char* argv[], size_t lens[]);
void reset_request();
const redis_result** scan_keys(const char* cmd, const char* key,
int& cursor, size_t& size, const char* pattern,
const size_t* count);
/*******************************************************************/
void build(const char* cmd, const char* key,
const std::map<string, string>& attrs);
void build(const char* cmd, const char* key,
const std::map<string, const char*>& attrs);
void build(const char* cmd, const char* key,
const std::map<int, string>& attrs);
void build(const char* cmd, const char* key,
const std::map<int, const char*>& attrs);
void build(const char* cmd, const char* key,
const std::vector<string>& names,
const std::vector<string>& values);
void build(const char* cmd, const char* key,
const std::vector<const char*>& names,
const std::vector<const char*>& values);
void build(const char* cmd, const char* key,
const std::vector<int>& names,
const std::vector<string>& values);
void build(const char* cmd, const char* key,
const std::vector<int>& names,
const std::vector<const char*>& values);
void build(const char* cmd, const char* key,
const char* names[], const char* values[], size_t argc);
void build(const char* cmd, const char* key,
const int names[], const char* values[], size_t argc);
void build(const char* cmd, const char* key,
const char* names[], const size_t names_len[],
const char* values[], const size_t values_len[], size_t argc);
/*******************************************************************/
void build(const char* cmd, const char* key,
const std::vector<string>& names);
void build(const char* cmd, const char* key,
const std::vector<const char*>& names);
void build(const char* cmd, const char* key,
const std::vector<int>& names);
void build(const char* cmd, const char* key,
const char* names[], size_t argc);
void build(const char* cmd, const char* key,
const int names[], size_t argc);
void build(const char* cmd, const char* key,
const char* names[], const size_t lens[], size_t argc);
protected:
int get_number(bool* success = NULL);
long long int get_number64(bool* success = NULL);
int get_number(std::vector<int>& out);
int get_number64(std::vector<long long int>& out);
bool check_status(const char* success = "OK");
int get_status(std::vector<bool>& out);
const char* get_status();
int get_string(string& buf);
int get_string(string* buf);
int get_string(char* buf, size_t size);
int get_strings(std::vector<string>& result);
int get_strings(std::vector<string>* result);
int get_strings(std::map<string, string>& result);
int get_strings(std::vector<string>& names,
std::vector<string>& values);
int get_strings(std::vector<const char*>& names,
std::vector<const char*>& values);
/************************** common *********************************/
protected:
dbuf_pool* pool_;
private:
redis_client* conn_;
unsigned long long used_;
private:
/************************** request ********************************/
bool slice_req_;
string* request_buf_;
redis_request* request_obj_;
size_t argv_size_;
const char** argv_;
size_t* argv_lens_;
size_t argc_;
void argv_space(size_t n);
void build_request1(size_t argc, const char* argv[], size_t lens[]);
void build_request2(size_t argc, const char* argv[], size_t lens[]);
private:
/************************** respond ********************************/
bool slice_res_;
const redis_result* result_;
};
} // namespace acl

View File

@ -10,7 +10,9 @@ all:
@(cd redis_zset_pool; make)
@(cd redis_set; make)
@(cd redis_connection; make)
@(cd redis_hyperloglog; make)
@(cd redis_trans; make)
# @(cd redis_server; make)
clean:
@(cd redis_key; make clean)
@ -24,4 +26,6 @@ clean:
@(cd redis_zset_pool; make clean)
@(cd redis_set; make clean)
@(cd redis_connection; make clean)
@(cd redis_hyperloglog; make clean)
@(cd redis_trans; make clean)
# @(cd redis_server; make clean)

View File

@ -68,14 +68,14 @@ static bool test_hmget(acl::redis_hash& option, int n)
else if (i >= 10)
continue;
size_t size = option.get_size();
size_t size = option.result_size();
printf("size: %lu, key: %s\r\n", (unsigned long) size,
key.c_str());
size_t j;
for (j = 0; j < size; j++)
{
const char* val = option.get_value(j);
const char* val = option.result_value(j);
printf("hmget ok, %s=%s\r\n",
attrs[j], val ? val : "null");
}

View File

@ -231,13 +231,13 @@ static bool test_mget(acl::redis_string& option, int n)
else if (i >= 10)
continue;
size_t size = option.get_size();
size_t size = option.result_size();
printf("size: %lu\r\n", (unsigned long) size);
size_t j;
for (j = 0; j < size; j++)
{
const char* val = option.get_value(j);
const char* val = option.result_value(j);
printf("mget ok, %s=%s\r\n",
keys[j], val ? val : "null");
}
@ -638,7 +638,7 @@ static void usage(const char* procname)
"-C connect_timeout[default: 10]\r\n"
"-I rw_timeout[default: 10]\r\n"
"-t object timeout[default: 10]\r\n"
"-a cmd[set|setex|setnx|append|get|getset|strlen|mset|mget|msetnx|setrange|getrange|setbit|getbit|bitcount|bitop_and|bitop_or|bitop_xor|incr|incrby|incrybfloat|decr|decrby]\r\n",
"-a cmd[set|setex|setnx|append|get|getset|strlen|mset|mget|msetnx|setrange|getrange|setbit|getbit|bitcount|bitop_and|bitop_or|bitop_xor|incr|incrby|incrbyfloat|decr|decrby]\r\n",
procname);
}

View File

@ -9,7 +9,7 @@ static bool test_zadd(acl::redis_zset& option, int i, const char* key,
nmember++;
// 从连接对象中获得统一的内存池分配对象,分配小内存块
acl::dbuf_pool* pool = option.get_client()->get_pool();
acl::dbuf_pool* pool = option.get_pool();
// 动态分配数据块指针数组内存
const char** members = (const char**)
pool->dbuf_alloc(nmember * sizeof(char*));
@ -238,8 +238,7 @@ protected:
// 每个线程一个 ID 号,做为键值组成部分
key.format("%s_%d_%d", __keypre.c_str(), id_, i);
conn->reset();
option.reset();
// 将 redis 连接对象与 redis 命令操作类对象进行绑定关联
option.set_client(conn);

View File

@ -1,5 +1,5 @@
#!/bin/sh
time ./redis_zset_pool -s 127.0.0.1:6380 -n 20000 -c 10 -a zadd -l 10240 -b 1024
time ./redis_zset_pool -s 127.0.0.1:6380 -n 20000 -c 10 -a zrange -l 10240 -b 1024 -S
time ./redis_zset_pool -s 127.0.0.1:6380 -n 20000 -c 10 -a zrange -l 10240 -b 1024
time ./redis_zset_pool -s 127.0.0.1:6380 -n 20000 -c 10 -a del
time ./redis_zset_pool -s 127.0.0.1:6379 -n 20000 -c 10 -a zadd -l 10240 -b 1024
time ./redis_zset_pool -s 127.0.0.1:6379 -n 20000 -c 10 -a zrange -l 10240 -b 1024 -S
time ./redis_zset_pool -s 127.0.0.1:6379 -n 20000 -c 10 -a zrange -l 10240 -b 1024
time ./redis_zset_pool -s 127.0.0.1:6379 -n 20000 -c 10 -a del

View File

@ -1,3 +1,3 @@
#!/bin/sh
valgrind --tool=memcheck --leak-check=yes -v ./redis_zset_pool -s 127.0.0.1:6380 -a all -n 10 -c 10 -l 10240 -b 1024 -S
valgrind --tool=memcheck --leak-check=yes -v ./redis_zset_pool -s 127.0.0.1:6369 -a all -n 10 -c 10 -l 10240 -b 1024 -S

View File

@ -29,8 +29,8 @@ bool redis_connection::auth(const char* passwd)
argv[1] = passwd;
lens[1] = strlen(passwd);
conn_->build_request(2, argv, lens);
return conn_->get_status();
build_request(2, argv, lens);
return check_status();
}
bool redis_connection::select(int dbnum)
@ -46,8 +46,8 @@ bool redis_connection::select(int dbnum)
argv[1] = buf;
lens[1] = strlen(argv[1]);
conn_->build_request(2, argv, lens);
return conn_->get_status();
build_request(2, argv, lens);
return check_status();
}
bool redis_connection::ping()
@ -58,8 +58,8 @@ bool redis_connection::ping()
argv[0] = "PING";
lens[0] = strlen(argv[0]);
conn_->build_request(1, argv, lens);
return conn_->get_status("PONG");
build_request(1, argv, lens);
return check_status("PONG");
}
bool redis_connection::echo(const char* s)
@ -74,8 +74,8 @@ bool redis_connection::echo(const char* s)
lens[1] = strlen(argv[1]);
string buf;
conn_->build_request(2, argv, lens);
return conn_->get_string(buf) >= 0 ? true : false;
build_request(2, argv, lens);
return get_string(buf) >= 0 ? true : false;
}
bool redis_connection::quit()
@ -86,10 +86,8 @@ bool redis_connection::quit()
argv[0] = "QUIT";
lens[0] = strlen(argv[0]);
conn_->build_request(1, argv, lens);
bool ret = conn_->get_status();
conn_->close();
return ret;
build_request(1, argv, lens);
return check_status();
}
} // namespace acl

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -24,26 +24,26 @@ redis_hash::~redis_hash()
bool redis_hash::hmset(const char* key, const std::map<string, string>& attrs)
{
conn_->build("HMSET", key, attrs);
return conn_->get_status();
build("HMSET", key, attrs);
return check_status();
}
bool redis_hash::hmset(const char* key, const std::map<string, const char*>& attrs)
{
conn_->build("HMSET", key, attrs);
return conn_->get_status();
build("HMSET", key, attrs);
return check_status();
}
bool redis_hash::hmset(const char* key, const std::map<int, string>& attrs)
{
conn_->build("HMSET", key, attrs);
return conn_->get_status();
build("HMSET", key, attrs);
return check_status();
}
bool redis_hash::hmset(const char* key, const std::map<int, const char*>& attrs)
{
conn_->build("HMSET", key, attrs);
return conn_->get_status();
build("HMSET", key, attrs);
return check_status();
}
/////////////////////////////////////////////////////////////////////////////
@ -51,43 +51,43 @@ bool redis_hash::hmset(const char* key, const std::map<int, const char*>& attrs)
bool redis_hash::hmget(const char* key, const std::vector<string>& names,
std::vector<string>* result /* = NULL */)
{
conn_->build("HMGET", key, names);
return conn_->get_strings(result) >= 0 ? true : false;
build("HMGET", key, names);
return get_strings(result) >= 0 ? true : false;
}
bool redis_hash::hmget(const char* key, const std::vector<const char*>& names,
std::vector<string>* result /* = NULL */)
{
conn_->build("HMGET", key, names);
return conn_->get_strings(result) >= 0 ? true : false;
build("HMGET", key, names);
return get_strings(result) >= 0 ? true : false;
}
bool redis_hash::hmget(const char* key, const std::vector<int>& names,
std::vector<string>* result /* = NULL */)
{
conn_->build("HMGET", key, names);
return conn_->get_strings(result) >= 0 ? true : false;
build("HMGET", key, names);
return get_strings(result) >= 0 ? true : false;
}
bool redis_hash::hmget(const char* key, const char* names[], size_t argc,
std::vector<string>* result /* = NULL */)
{
conn_->build("HMGET", key, names, argc);
return conn_->get_strings(result) >= 0 ? true : false;
build("HMGET", key, names, argc);
return get_strings(result) >= 0 ? true : false;
}
bool redis_hash::hmget(const char* key, const int names[], size_t argc,
std::vector<string>* result /* = NULL */)
{
conn_->build("HMGET", key, names, argc);
return conn_->get_strings(result) >= 0 ? true : false;
build("HMGET", key, names, argc);
return get_strings(result) >= 0 ? true : false;
}
bool redis_hash::hmget(const char* key, const char* names[],
const size_t lens[], size_t argc, std::vector<string>* result /* = NULL */)
{
conn_->build("HMGET", key, names, lens, argc);
return conn_->get_strings(result) >= 0 ? true : false;
build("HMGET", key, names, lens, argc);
return get_strings(result) >= 0 ? true : false;
}
/////////////////////////////////////////////////////////////////////////////
@ -118,8 +118,8 @@ int redis_hash::hset(const char* key, const char* name, size_t name_len,
argv[3] = value;
lens[3] = value_len;
conn_->build_request(4, argv, lens);
return conn_->get_number();
build_request(4, argv, lens);
return get_number();
}
int redis_hash::hsetnx(const char* key, const char* name, const char* value)
@ -148,8 +148,8 @@ int redis_hash::hsetnx(const char* key, const char* name, size_t name_len,
argv[3] = value;
lens[3] = value_len;
conn_->build_request(4, argv, lens);
return conn_->get_number();
build_request(4, argv, lens);
return get_number();
}
bool redis_hash::hget(const char* key, const char* name, string& result)
@ -170,8 +170,8 @@ bool redis_hash::hget(const char* key, const char* name,
argv[2] = name;
lens[2] = name_len;
conn_->build_request(3, argv, lens);
return conn_->get_string(result) >= 0 ? true : false;
build_request(3, argv, lens);
return get_string(result) >= 0 ? true : false;
}
bool redis_hash::hgetall(const char* key, std::map<string, string>& result)
@ -179,8 +179,8 @@ bool redis_hash::hgetall(const char* key, std::map<string, string>& result)
const char* keys[1];
keys[0] = key;
conn_->build("HGETALL", NULL, keys, 1);
return conn_->get_strings(result) < 0 ? false : true;
build("HGETALL", NULL, keys, 1);
return get_strings(result) < 0 ? false : true;
}
bool redis_hash::hgetall(const char* key, std::vector<string>& names,
@ -189,8 +189,8 @@ bool redis_hash::hgetall(const char* key, std::vector<string>& names,
const char* keys[1];
keys[0] = key;
conn_->build("HGETALL", NULL, keys, 1);
return conn_->get_strings(names, values) < 0 ? false : true;
build("HGETALL", NULL, keys, 1);
return get_strings(names, values) < 0 ? false : true;
}
bool redis_hash::hgetall(const char* key, std::vector<const char*>& names,
@ -199,8 +199,8 @@ bool redis_hash::hgetall(const char* key, std::vector<const char*>& names,
const char* keys[1];
keys[0] = key;
conn_->build("HGETALL", NULL, keys, 1);
return conn_->get_strings(names, values) < 0 ? false : true;
build("HGETALL", NULL, keys, 1);
return get_strings(names, values) < 0 ? false : true;
}
int redis_hash::hdel(const char* key, const char* first_name, ...)
@ -217,27 +217,27 @@ int redis_hash::hdel(const char* key, const char* first_name, ...)
int redis_hash::hdel(const char* key, const char* names[], size_t argc)
{
conn_->build("HDEL", key, names, argc);
return conn_->get_number();
build("HDEL", key, names, argc);
return get_number();
}
int redis_hash::hdel(const char* key, const char* names[],
const size_t names_len[], size_t argc)
{
conn_->build("HDEL", key, names, names_len, argc);
return conn_->get_number();;
build("HDEL", key, names, names_len, argc);
return get_number();;
}
int redis_hash::hdel(const char* key, const std::vector<string>& names)
{
conn_->build("HDEL", key, names);
return conn_->get_number();
build("HDEL", key, names);
return get_number();
}
int redis_hash::hdel(const char* key, const std::vector<const char*>& names)
{
conn_->build("HDEL", key, names);
return conn_->get_number();
build("HDEL", key, names);
return get_number();
}
bool redis_hash::hincrby(const char* key, const char* name,
@ -251,14 +251,14 @@ bool redis_hash::hincrby(const char* key, const char* name,
const char* values[1];
values[0] = buf;
conn_->build("HINCRBY", key, names, values, 1);
build("HINCRBY", key, names, values, 1);
bool success;
if (result != NULL)
*result = conn_->get_number64(&success);
*result = get_number64(&success);
else
(void) conn_->get_number64(&success);
(void) get_number64(&success);
return success;
}
@ -274,8 +274,8 @@ bool redis_hash::hincrbyfloat(const char* key, const char* name,
(void) safe_snprintf(buf, sizeof(buf), "%f", inc);
values[0] = buf;
conn_->build("HINCRBYFLOAT", key, names, values, 1);
if (conn_->get_string(buf, sizeof(buf)) == false)
build("HINCRBYFLOAT", key, names, values, 1);
if (get_string(buf, sizeof(buf)) == false)
return false;
if (result != NULL)
@ -290,8 +290,8 @@ bool redis_hash::hkeys(const char* key, std::vector<string>& names)
const char* keys[1];
keys[0] = key;
conn_->build("HKEYS", NULL, keys, 1);
return conn_->get_strings(names) < 0 ? false : true;
build("HKEYS", NULL, keys, 1);
return get_strings(names) < 0 ? false : true;
}
bool redis_hash::hexists(const char* key, const char* name)
@ -306,8 +306,8 @@ bool redis_hash::hexists(const char* key, const char* name, size_t name_len)
size_t names_len[1];
names_len[0] = name_len;
conn_->build("HEXISTS", key, names, names_len, 1);
return conn_->get_number() < 0 ? false : true;
build("HEXISTS", key, names, names_len, 1);
return get_number() < 0 ? false : true;
}
int redis_hash::hlen(const char* key)
@ -315,8 +315,8 @@ int redis_hash::hlen(const char* key)
const char* keys[1];
keys[0] = key;
conn_->build("HLEN", NULL, keys, 1);
return conn_->get_number();
build("HLEN", NULL, keys, 1);
return get_number();
}
int redis_hash::hscan(const char* key, int cursor, std::map<string, string>& out,

View File

@ -34,15 +34,15 @@ int redis_hyperloglog::pfadd(const char* key, const char* first_element, ...)
int redis_hyperloglog::pfadd(const char* key,
const std::vector<const char*>& elements)
{
conn_->build("PFADD", key, elements);
return conn_->get_number();
build("PFADD", key, elements);
return get_number();
}
int redis_hyperloglog::pfadd(const char* key,
const std::vector<string>& elements)
{
conn_->build("PFADD", key, elements);
return conn_->get_number();
build("PFADD", key, elements);
return get_number();
}
int redis_hyperloglog::pfcount(const char* first_key, ...)
@ -62,14 +62,14 @@ int redis_hyperloglog::pfcount(const char* first_key, ...)
int redis_hyperloglog::pfcount(const std::vector<const char*>& keys)
{
conn_->build("PFCOUNT", NULL, keys);
return conn_->get_number();
build("PFCOUNT", NULL, keys);
return get_number();
}
int redis_hyperloglog::pfcount(const std::vector<string>& keys)
{
conn_->build("PFCOUNT", NULL, keys);
return conn_->get_number();
build("PFCOUNT", NULL, keys);
return get_number();
}
bool redis_hyperloglog::pfmerge(const char* dst, const char* first_src, ...)
@ -90,15 +90,15 @@ bool redis_hyperloglog::pfmerge(const char* dst, const char* first_src, ...)
bool redis_hyperloglog::pfmerge(const char* dst,
const std::vector<const char*>& keys)
{
conn_->build("PFMERGE", dst, keys);
return conn_->get_status();
build("PFMERGE", dst, keys);
return check_status();
}
bool redis_hyperloglog::pfmerge(const char* dst,
const std::vector<string>& keys)
{
conn_->build("PFMERGE", dst, keys);
return conn_->get_status();
build("PFMERGE", dst, keys);
return check_status();
}
} //namespace acl

View File

@ -40,38 +40,38 @@ int redis_key::del(const char* first_key, ...)
int redis_key::del(const std::vector<string>& keys)
{
conn_->build("DEL", NULL, keys);
return conn_->get_number();
build("DEL", NULL, keys);
return get_number();
}
int redis_key::del(const std::vector<const char*>& keys)
{
conn_->build("DEL", NULL, keys);
return conn_->get_number();
build("DEL", NULL, keys);
return get_number();
}
int redis_key::del(const std::vector<int>& keys)
{
conn_->build("DEL", NULL, keys);
return conn_->get_number();
build("DEL", NULL, keys);
return get_number();
}
int redis_key::del(const char* keys[], size_t argc)
{
conn_->build("DEL", NULL, keys, argc);
return conn_->get_number();
build("DEL", NULL, keys, argc);
return get_number();
}
int redis_key::del(const int keys[], size_t argc)
{
conn_->build("DEL", NULL, keys, argc);
return conn_->get_number();
build("DEL", NULL, keys, argc);
return get_number();
}
int redis_key::del(const char* keys[], const size_t lens[], size_t argc)
{
conn_->build("DEL", NULL, keys, lens, argc);
return conn_->get_number();
build("DEL", NULL, keys, lens, argc);
return get_number();
}
int redis_key::dump(const char* key, string& out)
@ -85,8 +85,8 @@ int redis_key::dump(const char* key, string& out)
argv[1] = key;
lens[1] = strlen(key);
conn_->build_request(2, argv, lens);
return conn_->get_string(out);
build_request(2, argv, lens);
return get_string(out);
}
bool redis_key::exists(const char* key)
@ -100,8 +100,8 @@ bool redis_key::exists(const char* key)
argv[1] = key;
lens[1] = strlen(key);
conn_->build_request(2, argv, lens);
return conn_->get_number() > 0 ? true : false;
build_request(2, argv, lens);
return get_number() > 0 ? true : false;
}
int redis_key::expire(const char* key, int n)
@ -120,8 +120,8 @@ int redis_key::expire(const char* key, int n)
argv[2] = buf;
lens[2] = strlen(buf);
conn_->build_request(3, argv, lens);
return conn_->get_number();
build_request(3, argv, lens);
return get_number();
}
int redis_key::expireat(const char* key, time_t stamp)
@ -141,8 +141,8 @@ int redis_key::expireat(const char* key, time_t stamp)
argv[2] = stamp_s;
lens[2] = strlen(stamp_s);
conn_->build_request(3, argv, lens);
return conn_->get_number();
build_request(3, argv, lens);
return get_number();
}
int redis_key::keys_pattern(const char* pattern, std::vector<string>* out)
@ -156,8 +156,8 @@ int redis_key::keys_pattern(const char* pattern, std::vector<string>* out)
argv[1] = pattern;
lens[1] = strlen(pattern);
conn_->build_request(2, argv, lens);
return conn_->get_strings(out);
build_request(2, argv, lens);
return get_strings(out);
}
int redis_key::persist(const char* key)
@ -171,8 +171,8 @@ int redis_key::persist(const char* key)
argv[1] = key;
lens[1] = strlen(key);
conn_->build_request(2, argv, lens);
return conn_->get_number();
build_request(2, argv, lens);
return get_number();
}
int redis_key::pexpire(const char* key, int n)
@ -191,8 +191,8 @@ int redis_key::pexpire(const char* key, int n)
argv[2] = buf;
lens[2] = strlen(buf);
conn_->build_request(3, argv, lens);
return conn_->get_number();
build_request(3, argv, lens);
return get_number();
}
int redis_key::pexpireat(const char* key, long long int stamp)
@ -212,8 +212,8 @@ int redis_key::pexpireat(const char* key, long long int stamp)
argv[2] = stamp_s;
lens[2] = strlen(stamp_s);
conn_->build_request(3, argv, lens);
return conn_->get_number();
build_request(3, argv, lens);
return get_number();
}
long long int redis_key::pttl(const char* key)
@ -227,10 +227,10 @@ long long int redis_key::pttl(const char* key)
argv[1] = key;
lens[1] = strlen(key);
conn_->build_request(2, argv, lens);
build_request(2, argv, lens);
bool success;
long long int ret = conn_->get_number64(&success);
long long int ret = get_number64(&success);
if (success == false)
return -3;
else
@ -245,8 +245,8 @@ bool redis_key::randmkey(string& buf)
argv[0] = "RANDOMKEY";
lens[0] = sizeof("RANDOMKEY");
conn_->build_request(1, argv, lens);
return conn_->get_string(buf) > 0 ? true : false;
build_request(1, argv, lens);
return get_string(buf) > 0 ? true : false;
}
bool redis_key::rename_key(const char* key, const char* newkey)
@ -263,8 +263,8 @@ bool redis_key::rename_key(const char* key, const char* newkey)
argv[2] = newkey;
lens[2] = strlen(newkey);
conn_->build_request(3, argv, lens);
return conn_->get_status();
build_request(3, argv, lens);
return check_status();
}
bool redis_key::renamenx(const char* key, const char* newkey)
@ -281,8 +281,8 @@ bool redis_key::renamenx(const char* key, const char* newkey)
argv[2] = newkey;
lens[2] = strlen(newkey);
conn_->build_request(3, argv, lens);
return conn_->get_status();
build_request(3, argv, lens);
return check_status();
}
bool redis_key::restore(const char* key, const char* value, size_t len,
@ -313,8 +313,8 @@ bool redis_key::restore(const char* key, const char* value, size_t len,
argc++;
}
conn_->build_request(argc, argv, lens);
return conn_->get_status();
build_request(argc, argv, lens);
return check_status();
}
int redis_key::ttl(const char* key)
@ -328,10 +328,10 @@ int redis_key::ttl(const char* key)
argv[1] = key;
lens[1] = strlen(key);
conn_->build_request(2, argv, lens);
build_request(2, argv, lens);
bool success;
int ret = conn_->get_number(&success);
int ret = get_number(&success);
if (success == false)
return -3;
else
@ -350,8 +350,9 @@ redis_key_t redis_key::type(const char* key)
argv[1] = key;
lens[1] = strlen(key);
conn_->build_request(2, argv, lens);
const char* ptr = conn_->get_status_string();
build_request(2, argv, lens);
const char* ptr = get_status();
if (ptr == NULL || *ptr == 0)
return REDIS_KEY_UNKNOWN;
@ -415,8 +416,8 @@ bool redis_key::migrate(const char* key, const char* addr, unsigned dest_db,
argc++;
}
conn_->build_request(argc, argv, lens);
return conn_->get_status();
build_request(argc, argv, lens);
return check_status();
}
int redis_key::move(const char* key, unsigned dest_db)
@ -434,8 +435,8 @@ int redis_key::move(const char* key, unsigned dest_db)
argv[2] = db_s;
lens[2] = strlen(db_s);
conn_->build_request(3, argv, lens);
return conn_->get_number();
build_request(3, argv, lens);
return get_number();
}
int redis_key::object_refcount(const char* key)
@ -452,8 +453,8 @@ int redis_key::object_refcount(const char* key)
argv[2] = key;
lens[2] = strlen(key);
conn_->build_request(3, argv, lens);
return conn_->get_number();
build_request(3, argv, lens);
return get_number();
}
bool redis_key::object_encoding(const char* key, string& out)
@ -470,8 +471,8 @@ bool redis_key::object_encoding(const char* key, string& out)
argv[2] = key;
lens[2] = strlen(key);
conn_->build_request(3, argv, lens);
return conn_->get_string(out) > 0 ? true : false;
build_request(3, argv, lens);
return get_string(out) > 0 ? true : false;
}
int redis_key::object_idletime(const char* key)
@ -488,8 +489,8 @@ int redis_key::object_idletime(const char* key)
argv[2] = key;
lens[2] = strlen(key);
conn_->build_request(3, argv, lens);
return conn_->get_number();
build_request(3, argv, lens);
return get_number();
}
int redis_key::scan(int cursor, std::vector<string>& out,

View File

@ -35,8 +35,8 @@ int redis_list::llen(const char* key)
argv[1] = key;
lens[1] = strlen(key);
conn_->build_request(2, argv, lens);
return conn_->get_number();
build_request(2, argv, lens);
return get_number();
}
bool redis_list::lindex(const char* key, size_t idx, string& buf)
@ -54,8 +54,8 @@ bool redis_list::lindex(const char* key, size_t idx, string& buf)
argv[2] = tmp;
lens[2] = strlen(tmp);
conn_->build_request(3, argv, lens);
return conn_->get_string(buf) >= 0 ? true : false;
build_request(3, argv, lens);
return get_string(buf) >= 0 ? true : false;
}
bool redis_list::lset(const char* key, int idx, const char* value)
@ -81,8 +81,8 @@ bool redis_list::lset(const char* key, int idx, const char* value, size_t len)
argv[3] = value;
lens[3] = len;
conn_->build_request(4, argv, lens);
return conn_->get_status();
build_request(4, argv, lens);
return check_status();
}
int redis_list::linsert_before(const char* key, const char* pivot,
@ -126,8 +126,8 @@ int redis_list::linsert(const char* key, const char* pos, const char* pivot,
argv[4] = value;
lens[4] = value_len;
conn_->build_request(5, argv, lens);
return conn_->get_number();
build_request(5, argv, lens);
return get_number();
}
int redis_list::lpush(const char* key, const char* first_value, ...)
@ -148,27 +148,27 @@ int redis_list::lpush(const char* key, const char* first_value, ...)
int redis_list::lpush(const char* key, const char* values[], size_t argc)
{
conn_->build("LPUSH", key, values, argc);
return conn_->get_number();
build("LPUSH", key, values, argc);
return get_number();
}
int redis_list::lpush(const char* key, const std::vector<string>& values)
{
conn_->build("LPUSH", key, values);
return conn_->get_number();
build("LPUSH", key, values);
return get_number();
}
int redis_list::lpush(const char* key, const std::vector<const char*>& values)
{
conn_->build("LPUSH", key, values);
return conn_->get_number();
build("LPUSH", key, values);
return get_number();
}
int redis_list::lpush(const char* key, const char* values[],
const size_t lens[], size_t argc)
{
conn_->build("LPUSH", key, values, lens, argc);
return conn_->get_number();
build("LPUSH", key, values, lens, argc);
return get_number();
}
int redis_list::rpush(const char* key, const char* first_value, ...)
@ -189,27 +189,27 @@ int redis_list::rpush(const char* key, const char* first_value, ...)
int redis_list::rpush(const char* key, const char* values[], size_t argc)
{
conn_->build("RPUSH", key, values, argc);
return conn_->get_number();
build("RPUSH", key, values, argc);
return get_number();
}
int redis_list::rpush(const char* key, const std::vector<string>& values)
{
conn_->build("RPUSH", key, values);
return conn_->get_number();
build("RPUSH", key, values);
return get_number();
}
int redis_list::rpush(const char* key, const std::vector<const char*>& values)
{
conn_->build("RPUSH", key, values);
return conn_->get_number();
build("RPUSH", key, values);
return get_number();
}
int redis_list::rpush(const char* key, const char* values[],
const size_t lens[], size_t argc)
{
conn_->build("RPUSH", key, values, lens, argc);
return conn_->get_number();
build("RPUSH", key, values, lens, argc);
return get_number();
}
int redis_list::lpushx(const char* key, const char* value)
@ -245,8 +245,8 @@ int redis_list::pushx(const char* cmd, const char* key,
argv[2] = value;
lens[2] = len;
conn_->build_request(3, argv, lens);
return conn_->get_number();
build_request(3, argv, lens);
return get_number();
}
//////////////////////////////////////////////////////////////////////////
@ -271,8 +271,8 @@ int redis_list::pop(const char* cmd, const char* key, string& buf)
argv[1] = key;
lens[1] = strlen(key);
conn_->build_request(2, argv, lens);
return (int) conn_->get_string(buf);
build_request(2, argv, lens);
return (int) get_string(buf);
}
bool redis_list::blpop(std::pair<string, string>& result, size_t timeout,
@ -335,10 +335,8 @@ bool redis_list::bpop(const char* cmd, const std::vector<const char*>& keys,
size_t timeout, std::pair<string, string>& result)
{
size_t argc = 2 + keys.size();
dbuf_pool* pool = conn_->get_pool();
const char** args = (const char**)
pool->dbuf_alloc(argc * sizeof(char*));
size_t* lens = (size_t*) pool->dbuf_alloc(argc * sizeof(size_t));
const char** args = (const char**) pool_->dbuf_alloc(argc * sizeof(char*));
size_t* lens = (size_t*) pool_->dbuf_alloc(argc * sizeof(size_t));
args[0] = cmd;
lens[0] = strlen(cmd);
@ -357,7 +355,7 @@ bool redis_list::bpop(const char* cmd, const std::vector<const char*>& keys,
args[i] = buf;
lens[i] = strlen(args[i]);
conn_->build_request(argc, args, lens);
build_request(argc, args, lens);
return bpop(result);
}
@ -365,10 +363,8 @@ bool redis_list::bpop(const char* cmd, const std::vector<string>& keys,
size_t timeout, std::pair<string, string>& result)
{
size_t argc = 2 + keys.size();
dbuf_pool* pool = conn_->get_pool();
const char** args = (const char**)
pool->dbuf_alloc(argc * sizeof(char*));
size_t* lens = (size_t*) pool->dbuf_alloc(argc * sizeof(size_t));
const char** args = (const char**) pool_->dbuf_alloc(argc * sizeof(char*));
size_t* lens = (size_t*) pool_->dbuf_alloc(argc * sizeof(size_t));
args[0] = cmd;
lens[0] = strlen(cmd);
@ -387,13 +383,13 @@ bool redis_list::bpop(const char* cmd, const std::vector<string>& keys,
args[i] = buf;
lens[i] = strlen(args[i]);
conn_->build_request(argc, args, lens);
build_request(argc, args, lens);
return bpop(result);
}
bool redis_list::bpop(std::pair<string, string>& out)
{
const redis_result* result = conn_->run();
const redis_result* result = run();
if (result == NULL)
return false;
if (result->get_type() != REDIS_RESULT_ARRAY)
@ -435,8 +431,8 @@ bool redis_list::rpoplpush(const char* src, const char* dst,
argv[2] = dst;
lens[2] = strlen(dst);
conn_->build_request(3, argv, lens);
return conn_->get_string(buf) >= 0 ? true : false;
build_request(3, argv, lens);
return get_string(buf) >= 0 ? true : false;
}
bool redis_list::brpoplpush(const char* src, const char* dst,
@ -457,8 +453,8 @@ bool redis_list::brpoplpush(const char* src, const char* dst,
argv[3] = tmp;
lens[3] = strlen(argv[3]);
conn_->build_request(4, argv, lens);
return conn_->get_string(buf) >= 0 ? true : false;
build_request(4, argv, lens);
return get_string(buf) >= 0 ? true : false;
}
bool redis_list::lrange(const char* key, int start, int end,
@ -481,8 +477,8 @@ bool redis_list::lrange(const char* key, int start, int end,
argv[3] = end_s;
lens[3] = strlen(end_s);
conn_->build_request(4, argv, lens);
return conn_->get_strings(result) < 0 ? false : true;
build_request(4, argv, lens);
return get_strings(result) < 0 ? false : true;
}
int redis_list::lrem(const char* key, int count, const char* value)
@ -508,8 +504,8 @@ int redis_list::lrem(const char* key, int count, const char* value, size_t len)
argv[3] = value;
lens[3] = len;
conn_->build_request(4, argv, lens);
return conn_->get_number();
build_request(4, argv, lens);
return get_number();
}
bool redis_list::ltrim(const char* key, int start, int end)
@ -531,8 +527,8 @@ bool redis_list::ltrim(const char* key, int start, int end)
argv[3] = end_s;
lens[3] = strlen(end_s);
conn_->build_request(4, argv, lens);
return conn_->get_status();
build_request(4, argv, lens);
return check_status();
}
//////////////////////////////////////////////////////////////////////////

View File

@ -30,8 +30,8 @@ int redis_pubsub::publish(const char* channel, const char* msg, size_t len)
argv[2] = msg;
lens[2] = len;
conn_->build_request(3, argv, lens);
return conn_->get_number();
build_request(3, argv, lens);
return get_number();
}
int redis_pubsub::subscribe(const char* first_channel, ...)
@ -133,10 +133,8 @@ int redis_pubsub::punsubscribe(const std::vector<string>& patterns)
int redis_pubsub::subop(const char* cmd, const std::vector<const char*>& channels)
{
size_t argc = 1 + channels.size();
dbuf_pool* pool = conn_->get_pool();
const char** argv = (const char**)
pool->dbuf_alloc(argc * sizeof(char*));
size_t* lens = (size_t *) pool->dbuf_alloc(argc * sizeof(size_t));
const char** argv = (const char**) pool_->dbuf_alloc(argc * sizeof(char*));
size_t* lens = (size_t *) pool_->dbuf_alloc(argc * sizeof(size_t));
argv[0] = cmd;
lens[0] = strlen(cmd);
@ -148,8 +146,8 @@ int redis_pubsub::subop(const char* cmd, const std::vector<const char*>& channel
lens[i] = strlen(argv[i]);
}
conn_->build_request(argc, argv, lens);
const redis_result* result = conn_->run(channels.size());
build_request(argc, argv, lens);
const redis_result* result = run(channels.size());
if (result == NULL || result->get_type() != REDIS_RESULT_ARRAY)
return -1;
@ -172,10 +170,8 @@ int redis_pubsub::subop(const char* cmd, const std::vector<const char*>& channel
int redis_pubsub::subop(const char* cmd, const std::vector<string>& channels)
{
size_t argc = 1 + channels.size();
dbuf_pool* pool = conn_->get_pool();
const char** argv = (const char**)
pool->dbuf_alloc(argc * sizeof(char*));
size_t* lens = (size_t *) pool->dbuf_alloc(argc * sizeof(size_t));
const char** argv = (const char**) pool_->dbuf_alloc(argc * sizeof(char*));
size_t* lens = (size_t *) pool_->dbuf_alloc(argc * sizeof(size_t));
argv[0] = cmd;
lens[0] = strlen(cmd);
@ -187,8 +183,8 @@ int redis_pubsub::subop(const char* cmd, const std::vector<string>& channels)
lens[i] = (*cit).length();
}
conn_->build_request(argc, argv, lens);
const redis_result* result = conn_->run(channels.size());
build_request(argc, argv, lens);
const redis_result* result = run(channels.size());
if (result == NULL || result->get_type() != REDIS_RESULT_ARRAY)
return -1;
@ -241,8 +237,8 @@ int redis_pubsub::check_channel(const redis_result* obj, const char* cmd,
bool redis_pubsub::get_message(string& channel, string& msg)
{
conn_->reset_request();
const redis_result* result = conn_->run();
reset_request();
const redis_result* result = run();
if (result == NULL)
return false;
if (result->get_type() != REDIS_RESULT_ARRAY)
@ -294,15 +290,15 @@ int redis_pubsub::pubsub_channels(std::vector<string>* channels,
int redis_pubsub::pubsub_channels(const std::vector<const char*>& patterns,
std::vector<string>* channels)
{
conn_->build("PUBSUB", "CHANNELS", patterns);
return conn_->get_strings(channels);
build("PUBSUB", "CHANNELS", patterns);
return get_strings(channels);
}
int redis_pubsub::pubsub_channels(const std::vector<string>& patterns,
std::vector<string>* channels)
{
conn_->build("PUBSUB", "CHANNELS", patterns);
return conn_->get_strings(channels);
build("PUBSUB", "CHANNELS", patterns);
return get_strings(channels);
}
int redis_pubsub::pubsub_numsub(std::map<string, int>& out,
@ -325,20 +321,20 @@ int redis_pubsub::pubsub_numsub(std::map<string, int>& out,
int redis_pubsub::pubsub_numsub(const std::vector<const char*>& channels,
std::map<string, int>& out)
{
conn_->build("PUBSUB", "NUMSUB", channels);
build("PUBSUB", "NUMSUB", channels);
return pubsub_numsub(out);
}
int redis_pubsub::pubsub_numsub(const std::vector<string>& channels,
std::map<string, int>& out)
{
conn_->build("PUBSUB", "NUMSUB", channels);
build("PUBSUB", "NUMSUB", channels);
return pubsub_numsub(out);
}
int redis_pubsub::pubsub_numsub(std::map<string, int>& out)
{
const redis_result* result = conn_->run();
const redis_result* result = run();
if (result == NULL)
return -1;
@ -379,8 +375,8 @@ int redis_pubsub::pubsub_numpat()
argv[1] = "NUMPAT";
lens[1] = sizeof("NUMPAT") - 1;
conn_->build_request(2, argv, lens);
return conn_->get_number();
build_request(2, argv, lens);
return get_number();
}
} // namespace acl

View File

@ -364,10 +364,9 @@ const redis_result* redis_script::eval_cmd(const char* cmd,
const std::vector<string>& args)
{
size_t argc = 3 + keys.size() + args.size();
dbuf_pool* pool = conn_->get_pool();
const char** argv = (const char**)
pool->dbuf_alloc(argc * sizeof(char*));
size_t* lens = (size_t*) pool->dbuf_alloc(argc * sizeof(size_t));
pool_->dbuf_alloc(argc * sizeof(char*));
size_t* lens = (size_t*) pool_->dbuf_alloc(argc * sizeof(size_t));
argv[0] = cmd;
lens[0] = strlen(cmd);
@ -400,8 +399,8 @@ const redis_result* redis_script::eval_cmd(const char* cmd,
acl_assert(i == argc);
conn_->build_request(argc, argv, lens);
return conn_->run();
build_request(argc, argv, lens);
return run();
}
const redis_result* redis_script::eval_cmd(const char* cmd,
@ -410,10 +409,9 @@ const redis_result* redis_script::eval_cmd(const char* cmd,
const std::vector<const char*>& args)
{
size_t argc = 3 + keys.size() + args.size();
dbuf_pool* pool = conn_->get_pool();
const char** argv = (const char**)
pool->dbuf_alloc(argc * sizeof(char*));
size_t* lens = (size_t*) pool->dbuf_alloc(argc * sizeof(size_t));
pool_->dbuf_alloc(argc * sizeof(char*));
size_t* lens = (size_t*) pool_->dbuf_alloc(argc * sizeof(size_t));
argv[0] = cmd;
lens[0] = strlen(cmd);
@ -446,15 +444,15 @@ const redis_result* redis_script::eval_cmd(const char* cmd,
acl_assert(i == argc);
conn_->build_request(argc, argv, lens);
return conn_->run();
build_request(argc, argv, lens);
return run();
}
int redis_script::script_exists(const std::vector<string>& scripts,
std::vector<bool>& out)
{
conn_->build("SCRIPT", "EXISTS", scripts);
int ret = conn_->get_status(out);
build("SCRIPT", "EXISTS", scripts);
int ret = get_status(out);
if (ret != (int) scripts.size())
return -1;
return ret;
@ -463,8 +461,8 @@ int redis_script::script_exists(const std::vector<string>& scripts,
int redis_script::script_exists(const std::vector<const char*>& scripts,
std::vector<bool>& out)
{
conn_->build("SCRIPT", "EXISTS", scripts);
int ret = conn_->get_status(out);
build("SCRIPT", "EXISTS", scripts);
int ret = get_status(out);
if (ret != (int) scripts.size())
return -1;
return ret;
@ -481,8 +479,8 @@ bool redis_script::script_flush()
argv[1] = "FLUSH";
lens[1] = sizeof("FLUSH") - 1;
conn_->build_request(2, argv, lens);
return conn_->get_status();
build_request(2, argv, lens);
return check_status();
}
bool redis_script::script_load(const string& script, string& out)
@ -501,8 +499,8 @@ bool redis_script::script_load(const string& script, string& out)
argv[2] = script;
lens[2] = strlen(script);
conn_->build_request(3, argv, lens);
return conn_->get_string(out) > 0 ? true : false;
build_request(3, argv, lens);
return get_string(out) > 0 ? true : false;
}
bool redis_script::script_kill()
@ -516,8 +514,8 @@ bool redis_script::script_kill()
argv[1] = "KILL";
lens[1] = sizeof("KILL") - 1;
conn_->build_request(2, argv, lens);
return conn_->get_status();
build_request(2, argv, lens);
return check_status();
}
} // namespace acl

View File

@ -28,8 +28,8 @@ bool redis_server::bgrewriteaof()
argv[0] = "BGREWRITEAOF";
lens[0] = sizeof("BGREWRITEAOF") - 1;
conn_->build_request(1, argv, lens);
return conn_->get_status("Background");
build_request(1, argv, lens);
return check_status("Background");
}
bool redis_server::bgsave()
@ -40,8 +40,8 @@ bool redis_server::bgsave()
argv[0] = "BGSAVE";
lens[0] = sizeof("BGSAVE") - 1;
conn_->build_request(1, argv, lens);
return conn_->get_status();
build_request(1, argv, lens);
return check_status();
}
bool redis_server::client_getname(string& buf)
@ -55,8 +55,8 @@ bool redis_server::client_getname(string& buf)
argv[1] = "GETNAME";
lens[1] = sizeof("GETNAME") - 1;
conn_->build_request(2, argv, lens);
return conn_->get_string(buf) >0 ? true : false;
build_request(2, argv, lens);
return get_string(buf) >0 ? true : false;
}
bool redis_server::client_kill(const char* addr)
@ -73,8 +73,8 @@ bool redis_server::client_kill(const char* addr)
argv[2] = addr;
lens[2] = strlen(addr);
conn_->build_request(3, argv, lens);
return conn_->get_status();
build_request(3, argv, lens);
return check_status();
}
int redis_server::client_list(string& buf)
@ -88,8 +88,8 @@ int redis_server::client_list(string& buf)
argv[1] = "LIST";
lens[1] = sizeof("LIST") - 1;
conn_->build_request(2, argv, lens);
return conn_->get_string(buf);
build_request(2, argv, lens);
return get_string(buf);
}
bool redis_server::client_setname(const char* name)
@ -106,8 +106,8 @@ bool redis_server::client_setname(const char* name)
argv[2] = name;
lens[2] = strlen(name);
conn_->build_request(3, argv, lens);
return conn_->get_status();
build_request(3, argv, lens);
return check_status();
}
int redis_server::config_get(const char* parameter,
@ -125,8 +125,8 @@ int redis_server::config_get(const char* parameter,
argv[2] = parameter;
lens[2] = strlen(parameter);
conn_->build_request(3, argv, lens);
return conn_->get_strings(out);
build_request(3, argv, lens);
return get_strings(out);
}
bool redis_server::config_resetstat()
@ -140,8 +140,8 @@ bool redis_server::config_resetstat()
argv[1] = "RESETSTAT";
lens[1] = sizeof("RESETSTAT") - 1;
conn_->build_request(2, argv, lens);
return conn_->get_status();
build_request(2, argv, lens);
return check_status();
}
bool redis_server::config_rewrite()
@ -155,8 +155,8 @@ bool redis_server::config_rewrite()
argv[1] = "REWRITE";
lens[1] = sizeof("REWRITE") -1;
conn_->build_request(2, argv, lens);
return conn_->get_status();
build_request(2, argv, lens);
return check_status();
}
bool redis_server::config_set(const char* name, const char* value)
@ -176,8 +176,8 @@ bool redis_server::config_set(const char* name, const char* value)
argv[3] = value;
lens[3] = strlen(value);
conn_->build_request(4, argv, lens);
return conn_->get_status();
build_request(4, argv, lens);
return check_status();
}
int redis_server::dbsize()
@ -188,8 +188,8 @@ int redis_server::dbsize()
argv[0] = "DBSIZE";
lens[0] = sizeof("DBSIZE") - 1;
conn_->build_request(1, argv, lens);
return conn_->get_number();
build_request(1, argv, lens);
return get_number();
}
bool redis_server::flushall()
@ -200,8 +200,8 @@ bool redis_server::flushall()
argv[0] = "FLUSHALL";
lens[0] = sizeof("FLUSHALL") - 1;
conn_->build_request(1, argv, lens);
return conn_->get_status();
build_request(1, argv, lens);
return check_status();
}
bool redis_server::flushdb()
@ -212,8 +212,8 @@ bool redis_server::flushdb()
argv[0] = "FLUSHDB";
lens[0] = sizeof("FLUSHDB") - 1;
conn_->build_request(1, argv, lens);
return conn_->get_status();
build_request(1, argv, lens);
return check_status();
}
int redis_server::info(string& buf)
@ -224,8 +224,8 @@ int redis_server::info(string& buf)
argv[0] = "INFO";
lens[0] = sizeof("INFO") - 1;
conn_->build_request(1, argv, lens);
return conn_->get_string(buf);
build_request(1, argv, lens);
return get_string(buf);
}
time_t redis_server::lastsave()
@ -236,8 +236,8 @@ time_t redis_server::lastsave()
argv[0] = "LASTSAVE";
lens[0] = sizeof("LASTSAVE") - 1;
conn_->build_request(1, argv, lens);
return (time_t) conn_->get_number64();
build_request(1, argv, lens);
return (time_t) get_number64();
}
bool redis_server::monitor()
@ -248,14 +248,14 @@ bool redis_server::monitor()
argv[0] = "MONITOR";
lens[0] = sizeof("MONITOR") - 1;
conn_->build_request(1, argv, lens);
return conn_->get_status();
build_request(1, argv, lens);
return check_status();
}
bool redis_server::get_command(string& buf)
{
conn_->reset_request();
const redis_result* result = conn_->run();
reset_request();
const redis_result* result = run();
if (result == NULL || result->get_type() != REDIS_RESULT_STATUS)
return false;
const char* status = result->get_status();
@ -273,8 +273,8 @@ bool redis_server::save()
argv[0] = "SAVE";
lens[0] = sizeof("SAVE") - 1;
conn_->build_request(1, argv, lens);
return conn_->get_status();
build_request(1, argv, lens);
return check_status();
}
void redis_server::shutdown(bool save_data /* = true */)
@ -296,8 +296,8 @@ void redis_server::shutdown(bool save_data /* = true */)
lens[1] = sizeof("nosave") - 1;
}
conn_->build_request(2, argv, lens);
(void) conn_->get_status();
build_request(2, argv, lens);
(void) check_status();
}
bool redis_server::slaveof(const char* ip, int port)
@ -316,8 +316,8 @@ bool redis_server::slaveof(const char* ip, int port)
argv[2] = port_s;
lens[2] = strlen(port_s);
conn_->build_request(3, argv, lens);
return conn_->get_status();
build_request(3, argv, lens);
return check_status();
}
const redis_result* redis_server::slowlog_get(int number /* = 0 */)
@ -342,8 +342,8 @@ const redis_result* redis_server::slowlog_get(int number /* = 0 */)
argc++;
}
conn_->build_request(argc, argv, lens);
return conn_->run();
build_request(argc, argv, lens);
return run();
}
int redis_server::slowlog_len()
@ -357,8 +357,8 @@ int redis_server::slowlog_len()
argv[1] = "LEN";
lens[1] = sizeof("LEN") - 1;
conn_->build_request(2, argv, lens);
return conn_->get_number();
build_request(2, argv, lens);
return get_number();
}
bool redis_server::slowlog_reset()
@ -372,8 +372,8 @@ bool redis_server::slowlog_reset()
argv[1] = "RESET";
lens[1] = sizeof("RESET") - 1;
conn_->build_request(2, argv, lens);
return conn_->get_status();
build_request(2, argv, lens);
return check_status();
}
bool redis_server::get_time(time_t& stamp, int& escape)
@ -384,10 +384,10 @@ bool redis_server::get_time(time_t& stamp, int& escape)
argv[0] = "TIME";
lens[0] = sizeof("TIME") - 1;
conn_->build_request(1, argv, lens);
build_request(1, argv, lens);
std::vector<string> tokens;
if (conn_->get_strings(tokens) <= 0 || tokens.size() < 2)
if (get_strings(tokens) <= 0 || tokens.size() < 2)
return false;
stamp = atol(tokens[0].c_str());

View File

@ -36,28 +36,28 @@ int redis_set::sadd(const char* key, const char* first_member, ...)
int redis_set::sadd(const char* key, const std::vector<const char*>& memsbers)
{
conn_->build("SADD", key, memsbers);
return conn_->get_number();
build("SADD", key, memsbers);
return get_number();
}
int redis_set::sadd(const char* key, const std::vector<string>& members)
{
conn_->build("SADD", key, members);
return conn_->get_number();
build("SADD", key, members);
return get_number();
}
int redis_set::sadd(const char* key, const char* argv[], size_t argc)
{
conn_->build("SADD", key, argv, argc);
return conn_->get_number();
build("SADD", key, argv, argc);
return get_number();
}
int redis_set::sadd(const char* key, const char* argv[],
const size_t lens[], size_t argc)
{
conn_->build("SADD", key, argv, lens, argc);
return conn_->get_number();
build("SADD", key, argv, lens, argc);
return get_number();
}
bool redis_set::spop(const char* key, string& buf)
@ -70,8 +70,8 @@ bool redis_set::spop(const char* key, string& buf)
argv[1] = key;
lens[1] = strlen(key);
conn_->build_request(2, argv, lens);
return conn_->get_string(buf) < 0 ? false : true;
build_request(2, argv, lens);
return get_string(buf) < 0 ? false : true;
}
int redis_set::scard(const char* key)
@ -84,8 +84,8 @@ int redis_set::scard(const char* key)
argv[1] = key;
lens[1] = strlen(key);
conn_->build_request(2, argv, lens);
return conn_->get_number();
build_request(2, argv, lens);
return get_number();
}
int redis_set::smembers(const char* key, std::vector<string>* members)
@ -98,8 +98,8 @@ int redis_set::smembers(const char* key, std::vector<string>* members)
argv[1] = key;
lens[1] = strlen(key);
conn_->build_request(2, argv, lens);
return conn_->get_strings(members);
build_request(2, argv, lens);
return get_strings(members);
}
int redis_set::smove(const char* src, const char* dst, const char* member)
@ -127,8 +127,8 @@ int redis_set::smove(const char* src, const char* dst, const char* member,
argv[3] = member;
lens[3] = len;
conn_->build_request(4, argv, lens);
return conn_->get_number();
build_request(4, argv, lens);
return get_number();
}
int redis_set::sdiff(std::vector<string>* members, const char* first_key, ...)
@ -149,15 +149,15 @@ int redis_set::sdiff(std::vector<string>* members, const char* first_key, ...)
int redis_set::sdiff(const std::vector<const char*>& keys,
std::vector<string>* members)
{
conn_->build("SDIFF", NULL, keys);
return conn_->get_strings(members);
build("SDIFF", NULL, keys);
return get_strings(members);
}
int redis_set::sdiff(const std::vector<string>& keys,
std::vector<string>* members)
{
conn_->build("SDIFF", NULL, keys);
return conn_->get_strings(members);
build("SDIFF", NULL, keys);
return get_strings(members);
}
int redis_set::sinter(std::vector<string>* members, const char* first_key, ...)
@ -178,15 +178,15 @@ int redis_set::sinter(std::vector<string>* members, const char* first_key, ...)
int redis_set::sinter(const std::vector<const char*>& keys,
std::vector<string>* members)
{
conn_->build("SINTER", NULL, keys);
return conn_->get_strings(members);
build("SINTER", NULL, keys);
return get_strings(members);
}
int redis_set::sinter(const std::vector<string>& keys,
std::vector<string>* members)
{
conn_->build("SINTER", NULL, keys);
return conn_->get_strings(members);
build("SINTER", NULL, keys);
return get_strings(members);
}
int redis_set::sunion(std::vector<string>* members, const char* first_key, ...)
@ -207,15 +207,15 @@ int redis_set::sunion(std::vector<string>* members, const char* first_key, ...)
int redis_set::sunion(const std::vector<const char*>& keys,
std::vector<string>* members)
{
conn_->build("SUNION", NULL, keys);
return conn_->get_strings(members);
build("SUNION", NULL, keys);
return get_strings(members);
}
int redis_set::sunion(const std::vector<string>& keys,
std::vector<string>* members)
{
conn_->build("SUNION", NULL, keys);
return conn_->get_strings(members);
build("SUNION", NULL, keys);
return get_strings(members);
}
int redis_set::sdiffstore(const char* dst, const char* first_key, ...)
@ -233,14 +233,14 @@ int redis_set::sdiffstore(const char* dst, const char* first_key, ...)
int redis_set::sdiffstore(const char* dst, const std::vector<const char*>& keys)
{
conn_->build("SDIFFSTORE", dst, keys);
return conn_->get_number();
build("SDIFFSTORE", dst, keys);
return get_number();
}
int redis_set::sdiffstore(const char* dst, const std::vector<string>& keys)
{
conn_->build("SDIFFSTORE", dst, keys);
return conn_->get_number();
build("SDIFFSTORE", dst, keys);
return get_number();
}
int redis_set::sinterstore(const char* dst, const char* first_key, ...)
@ -258,14 +258,14 @@ int redis_set::sinterstore(const char* dst, const char* first_key, ...)
int redis_set::sinterstore(const char* dst, const std::vector<const char*>& keys)
{
conn_->build("SINTERSTORE", dst, keys);
return conn_->get_number();
build("SINTERSTORE", dst, keys);
return get_number();
}
int redis_set::sinterstore(const char* dst, const std::vector<string>& keys)
{
conn_->build("SINTERSTORE", dst, keys);
return conn_->get_number();
build("SINTERSTORE", dst, keys);
return get_number();
}
int redis_set::sunionstore(const char* dst, const char* first_key, ...)
@ -283,14 +283,14 @@ int redis_set::sunionstore(const char* dst, const char* first_key, ...)
int redis_set::sunionstore(const char* dst, const std::vector<const char*>& keys)
{
conn_->build("SUNIONSTORE", dst, keys);
return conn_->get_number();
build("SUNIONSTORE", dst, keys);
return get_number();
}
int redis_set::sunionstore(const char* dst, const std::vector<string>& keys)
{
conn_->build("SUNIONSTORE", dst, keys);
return conn_->get_number();
build("SUNIONSTORE", dst, keys);
return get_number();
}
bool redis_set::sismember(const char* key, const char* member)
@ -312,8 +312,8 @@ bool redis_set::sismember(const char* key, const char* member, size_t len)
argv[2] = member;
lens[2] = len;
conn_->build_request(3, argv, lens);
return conn_->get_number() > 0 ? true : false;
build_request(3, argv, lens);
return get_number() > 0 ? true : false;
}
int redis_set::srandmember(const char* key, string& out)
@ -327,8 +327,8 @@ int redis_set::srandmember(const char* key, string& out)
argv[1] = key;
lens[1] = strlen(key);
conn_->build_request(2, argv, lens);
return conn_->get_string(out);
build_request(2, argv, lens);
return get_string(out);
}
int redis_set::srandmember(const char* key, size_t n, std::vector<string>& out)
@ -347,8 +347,8 @@ int redis_set::srandmember(const char* key, size_t n, std::vector<string>& out)
argv[2] = buf;
lens[2] = strlen(buf);
conn_->build_request(3, argv, lens);
return conn_->get_strings(out);
build_request(3, argv, lens);
return get_strings(out);
}
int redis_set::srem(const char* key, const char* first_member, ...)
@ -367,21 +367,21 @@ int redis_set::srem(const char* key, const char* first_member, ...)
int redis_set::srem(const char* key, const std::vector<string>& members)
{
conn_->build("SREM", key, members);
return conn_->get_number();
build("SREM", key, members);
return get_number();
}
int redis_set::srem(const char* key, const std::vector<const char*>& members)
{
conn_->build("SREM", key, members);
return conn_->get_number();
build("SREM", key, members);
return get_number();
}
int redis_set::srem(const char* key, const char* members[],
size_t lens[], size_t argc)
{
conn_->build("SREM", key, members, lens, argc);
return conn_->get_number();
build("SREM", key, members, lens, argc);
return get_number();
}
int redis_set::sscan(const char* key, int cursor, std::vector<string>& out,

View File

@ -44,8 +44,8 @@ bool redis_string::set(const char* key, size_t key_len,
argv[2] = value;
lens[2] = value_len;
conn_->build_request(3, argv, lens);
return conn_->get_status();
build_request(3, argv, lens);
return check_status();
}
bool redis_string::setex(const char* key, const char* value, int timeout)
@ -73,8 +73,8 @@ bool redis_string::setex(const char* key, size_t key_len, const char* value,
argv[3] = value;
lens[3] = value_len;
conn_->build_request(4, argv, lens);
return conn_->get_status();
build_request(4, argv, lens);
return check_status();
}
bool redis_string::psetex(const char* key, const char* value, int timeout)
@ -102,8 +102,8 @@ bool redis_string::psetex(const char* key, size_t key_len, const char* value,
argv[3] = value;
lens[3] = value_len;
conn_->build_request(4, argv, lens);
return conn_->get_status();
build_request(4, argv, lens);
return check_status();
}
int redis_string::setnx(const char* key, const char* value)
@ -126,8 +126,8 @@ int redis_string::setnx(const char* key, size_t key_len,
argv[2] = value;
lens[2] = value_len;
conn_->build_request(3, argv, lens);
return conn_->get_number();
build_request(3, argv, lens);
return get_number();
}
int redis_string::append(const char* key, const char* value)
@ -149,8 +149,8 @@ int redis_string::append(const char* key, const char* value, size_t size)
argv[2] = value;
lens[2] = size;
conn_->build_request(3, argv, lens);
return conn_->get_number();
build_request(3, argv, lens);
return get_number();
}
bool redis_string::get(const char* key, string& buf)
@ -169,8 +169,8 @@ bool redis_string::get(const char* key, size_t len, string& buf)
argv[1] = key;
lens[1] = len;
conn_->build_request(2, argv, lens);
return conn_->get_string(buf) >= 0 ? true : false;
build_request(2, argv, lens);
return get_string(buf) >= 0 ? true : false;
}
const redis_result* redis_string::get(const char* key)
@ -189,8 +189,8 @@ const redis_result* redis_string::get(const char* key, size_t len)
argv[1] = key;
lens[1] = len;
conn_->build_request(2, argv, lens);
const redis_result* result = conn_->run();
build_request(2, argv, lens);
const redis_result* result = run();
if (result == NULL)
return NULL;
if (result->get_type() != REDIS_RESULT_STRING)
@ -218,8 +218,8 @@ bool redis_string::getset(const char* key, size_t key_len,
argv[2] = value;
lens[2] = value_len;
conn_->build_request(3, argv, lens);
return conn_->get_string(buf) >= 0 ? true : false;
build_request(3, argv, lens);
return get_string(buf) >= 0 ? true : false;
}
/////////////////////////////////////////////////////////////////////////////
@ -240,8 +240,8 @@ int redis_string::get_strlen(const char* key, size_t len)
argv[1] = key;
lens[1] = len;
conn_->build_request(2, argv, lens);
return conn_->get_number();
build_request(2, argv, lens);
return get_number();
}
int redis_string::setrange(const char* key, unsigned offset, const char* value)
@ -269,8 +269,8 @@ int redis_string::setrange(const char* key, size_t key_len, unsigned offset,
argv[3] = value;
lens[3] = value_len;
conn_->build_request(4, argv, lens);
return conn_->get_number();
build_request(4, argv, lens);
return get_number();
}
bool redis_string::getrange(const char* key, int start, int end, string& buf)
@ -299,8 +299,8 @@ bool redis_string::getrange(const char* key, size_t key_len,
argv[3] = end_buf;
lens[3] = strlen(end_buf);
conn_->build_request(4, argv, lens);
return conn_->get_string(buf) >= 0 ? true : false;
build_request(4, argv, lens);
return get_string(buf) >= 0 ? true : false;
}
/////////////////////////////////////////////////////////////////////////////
@ -330,8 +330,8 @@ bool redis_string::setbit(const char* key, size_t len,
argv[3] = bit ? "1" : "0";
lens[3] = 1;
conn_->build_request(4, argv, lens);
return conn_->get_number() >= 0 ? true : false;
build_request(4, argv, lens);
return get_number() >= 0 ? true : false;
}
bool redis_string::getbit(const char* key, unsigned offset, int& bit)
@ -356,8 +356,8 @@ bool redis_string::getbit(const char* key, size_t len,
argv[2] = buf4off;
lens[2] = strlen(buf4off);
conn_->build_request(3, argv, lens);
int ret = conn_->get_number();
build_request(3, argv, lens);
int ret = get_number();
if (ret < 0)
return false;
bit = ret == 0 ? 0 : 1;
@ -380,8 +380,8 @@ int redis_string::bitcount(const char* key, size_t len)
argv[1] = key;
lens[1] = len;
conn_->build_request(2, argv, lens);
return conn_->get_number();
build_request(2, argv, lens);
return get_number();
}
int redis_string::bitcount(const char* key, int start, int end)
@ -410,8 +410,8 @@ int redis_string::bitcount(const char* key, size_t len, int start, int end)
argv[3] = buf4end;
lens[3] = strlen(buf4end);
conn_->build_request(4, argv, lens);
return conn_->get_number();
build_request(4, argv, lens);
return get_number();
}
int redis_string::bitop_and(const char* destkey, const std::vector<string>& keys)
@ -499,9 +499,8 @@ int redis_string::bitop(const char* op, const char* destkey,
const std::vector<string>& keys)
{
size_t argc = 3 + keys.size();
dbuf_pool* pool = conn_->get_pool();
const char** argv = (const char**) pool->dbuf_alloc(argc * sizeof(char*));
size_t* lens = (size_t*) pool->dbuf_alloc(argc * sizeof(size_t));
const char** argv = (const char**) pool_->dbuf_alloc(argc * sizeof(char*));
size_t* lens = (size_t*) pool_->dbuf_alloc(argc * sizeof(size_t));
argv[0] = "BITOP";
lens[0] = sizeof("BITOP") - 1;
@ -519,17 +518,16 @@ int redis_string::bitop(const char* op, const char* destkey,
lens[i] = strlen(argv[i]);
}
conn_->build_request(argc, argv, lens);
return conn_->get_number();
build_request(argc, argv, lens);
return get_number();
}
int redis_string::bitop(const char* op, const char* destkey,
const std::vector<const char*>& keys)
{
size_t argc = 3 + keys.size();
dbuf_pool* pool = conn_->get_pool();
const char** argv = (const char**) pool->dbuf_alloc(argc * sizeof(char*));
size_t* lens = (size_t*) pool->dbuf_alloc(argc * sizeof(size_t));
const char** argv = (const char**) pool_->dbuf_alloc(argc * sizeof(char*));
size_t* lens = (size_t*) pool_->dbuf_alloc(argc * sizeof(size_t));
argv[0] = "BITOP";
lens[0] = sizeof("BITOP") - 1;
@ -547,17 +545,16 @@ int redis_string::bitop(const char* op, const char* destkey,
lens[i] = strlen(argv[i]);
}
conn_->build_request(argc, argv, lens);
return conn_->get_number();
build_request(argc, argv, lens);
return get_number();
}
int redis_string::bitop(const char* op, const char* destkey,
const char* keys[], size_t size)
{
size_t argc = 3 + size;
dbuf_pool* pool = conn_->get_pool();
const char** argv = (const char**) pool->dbuf_alloc(argc * sizeof(char*));
size_t* lens = (size_t*) pool->dbuf_alloc(argc * sizeof(size_t));
const char** argv = (const char**) pool_->dbuf_alloc(argc * sizeof(char*));
size_t* lens = (size_t*) pool_->dbuf_alloc(argc * sizeof(size_t));
argv[0] = "BITOP";
lens[0] = sizeof("BITOP") - 1;
@ -574,90 +571,90 @@ int redis_string::bitop(const char* op, const char* destkey,
lens[i] = strlen(argv[i]);
}
conn_->build_request(argc, argv, lens);
return conn_->get_number();
build_request(argc, argv, lens);
return get_number();
}
/////////////////////////////////////////////////////////////////////////////
bool redis_string::mset(const std::map<string, string>& objs)
{
conn_->build("MSET", NULL, objs);
return conn_->get_status();
build("MSET", NULL, objs);
return check_status();
}
bool redis_string::mset(const std::map<int, string>& objs)
{
conn_->build("MSET", NULL, objs);
return conn_->get_status();
build("MSET", NULL, objs);
return check_status();
}
bool redis_string::mset(const std::vector<string>& keys,
const std::vector<string>& values)
{
conn_->build("MSET", NULL, keys, values);
return conn_->get_status();
build("MSET", NULL, keys, values);
return check_status();
}
bool redis_string::mset(const std::vector<int>& keys,
const std::vector<string>& values)
{
conn_->build("MSET", NULL, keys, values);
return conn_->get_status();
build("MSET", NULL, keys, values);
return check_status();
}
bool redis_string::mset(const char* keys[], const char* values[], size_t argc)
{
conn_->build("MSET", NULL, keys, values, argc);
return conn_->get_status();
build("MSET", NULL, keys, values, argc);
return check_status();
}
bool redis_string::mset(const char* keys[], const size_t keys_len[],
const char* values[], const size_t values_len[], size_t argc)
{
conn_->build("MSET", NULL, keys, keys_len, values, values_len, argc);
return conn_->get_status();
build("MSET", NULL, keys, keys_len, values, values_len, argc);
return check_status();
}
/////////////////////////////////////////////////////////////////////////////
int redis_string::msetnx(const std::map<string, string>& objs)
{
conn_->build("MSETNX", NULL, objs);
return conn_->get_number();
build("MSETNX", NULL, objs);
return get_number();
}
int redis_string::msetnx(const std::map<int, string>& objs)
{
conn_->build("MSETNX", NULL, objs);
return conn_->get_number();
build("MSETNX", NULL, objs);
return get_number();
}
int redis_string::msetnx(const std::vector<string>& keys,
const std::vector<string>& values)
{
conn_->build("MSETNX", NULL, keys, values);
return conn_->get_number();
build("MSETNX", NULL, keys, values);
return get_number();
}
int redis_string::msetnx(const std::vector<int>& keys,
const std::vector<string>& values)
{
conn_->build("MSETNX", NULL, keys, values);
return conn_->get_number();
build("MSETNX", NULL, keys, values);
return get_number();
}
int redis_string::msetnx(const char* keys[], const char* values[], size_t argc)
{
conn_->build("MSETNX", NULL, keys, values, argc);
return conn_->get_number();
build("MSETNX", NULL, keys, values, argc);
return get_number();
}
int redis_string::msetnx(const char* keys[], const size_t keys_len[],
const char* values[], const size_t values_len[], size_t argc)
{
conn_->build("MSETNX", NULL, keys, keys_len, values, values_len, argc);
return conn_->get_number();
build("MSETNX", NULL, keys, keys_len, values, values_len, argc);
return get_number();
}
/////////////////////////////////////////////////////////////////////////////
@ -665,22 +662,22 @@ int redis_string::msetnx(const char* keys[], const size_t keys_len[],
bool redis_string::mget(const std::vector<string>& keys,
std::vector<string>* out /* = NULL */)
{
conn_->build("MGET", NULL, keys);
return conn_->get_strings(out) >= 0 ? true : false;
build("MGET", NULL, keys);
return get_strings(out) >= 0 ? true : false;
}
bool redis_string::mget(const std::vector<const char*>& keys,
std::vector<string>* out /* = NULL */)
{
conn_->build("MGET", NULL, keys);
return conn_->get_strings(out) >= 0 ? true : false;
build("MGET", NULL, keys);
return get_strings(out) >= 0 ? true : false;
}
bool redis_string::mget(const std::vector<int>& keys,
std::vector<string>* out /* = NULL */)
{
conn_->build("MGET", NULL, keys);
return conn_->get_strings(out) >= 0 ? true : false;
build("MGET", NULL, keys);
return get_strings(out) >= 0 ? true : false;
}
bool redis_string::mget(std::vector<string>* out, const char* first_key, ...)
@ -694,29 +691,29 @@ bool redis_string::mget(std::vector<string>* out, const char* first_key, ...)
keys.push_back(key);
va_end(ap);
conn_->build("MGET", NULL, keys);
return conn_->get_strings(out) >= 0 ? true : false;
build("MGET", NULL, keys);
return get_strings(out) >= 0 ? true : false;
}
bool redis_string::mget(const char* keys[], size_t argc,
std::vector<string>* out /* = NULL */)
{
conn_->build("MGET", NULL, keys, argc);
return conn_->get_strings(out) >= 0 ? true : false;
build("MGET", NULL, keys, argc);
return get_strings(out) >= 0 ? true : false;
}
bool redis_string::mget(const int keys[], size_t argc,
std::vector<string>* out /* = NULL */)
{
conn_->build("MGET", NULL, keys, argc);
return conn_->get_strings(out) >= 0 ? true : false;
build("MGET", NULL, keys, argc);
return get_strings(out) >= 0 ? true : false;
}
bool redis_string::mget(const char* keys[], const size_t keys_len[],
size_t argc, std::vector<string>* out /* = NULL */)
{
conn_->build("MGET", NULL, keys, keys_len, argc);
return conn_->get_strings(out) >= 0 ? true : false;
build("MGET", NULL, keys, keys_len, argc);
return get_strings(out) >= 0 ? true : false;
}
/////////////////////////////////////////////////////////////////////////////
@ -749,8 +746,8 @@ bool redis_string::incrbyfloat(const char* key, double inc,
argv[2] = buf;
lens[2] = strlen(buf);
conn_->build_request(3, argv, lens);
if (conn_->get_string(buf, sizeof(buf)) == false)
build_request(3, argv, lens);
if (get_string(buf, sizeof(buf)) == false)
return false;
if (result != NULL)
@ -791,13 +788,13 @@ bool redis_string::incoper(const char* cmd, const char* key, long long int n,
argc++;
}
conn_->build_request(argc, argv, lens);
build_request(argc, argv, lens);
bool success;
if (result != NULL)
*result = conn_->get_number64(&success);
*result = get_number64(&success);
else
(void) conn_->get_number64(&success);
(void) get_number64(&success);
return success;
}

View File

@ -20,8 +20,8 @@ redis_transaction::~redis_transaction()
bool redis_transaction::watch(const std::vector<string>& keys)
{
conn_->build("WATCH", NULL, keys);
return conn_->get_status();
build("WATCH", NULL, keys);
return check_status();
}
bool redis_transaction::unwatch()
@ -29,8 +29,8 @@ bool redis_transaction::unwatch()
const char* argv[1];
size_t lens[1];
conn_->build_request(1, argv, lens);
return conn_->get_status();
build_request(1, argv, lens);
return check_status();
}
bool redis_transaction::multi()
@ -43,8 +43,8 @@ bool redis_transaction::multi()
argv[0] = "MULTI";
lens[0] = sizeof("MULTI") - 1;
conn_->build_request(1, argv, lens);
return conn_->get_status();
build_request(1, argv, lens);
return check_status();
}
bool redis_transaction::exec()
@ -55,8 +55,8 @@ bool redis_transaction::exec()
argv[0] = "EXEC";
lens[0] = sizeof("EXEC") - 1;
conn_->build_request(1, argv, lens);
const redis_result* result = conn_->run();
build_request(1, argv, lens);
const redis_result* result = run();
if(result == NULL || result->get_type() != REDIS_RESULT_ARRAY)
return false;
@ -74,15 +74,15 @@ bool redis_transaction::discard()
argv[0] = "DISCARD";
lens[0] = sizeof("DISCARD") - 1;
conn_->build_request(1, argv, lens);
return conn_->get_status();
build_request(1, argv, lens);
return check_status();
}
bool redis_transaction::run_cmd(const char* cmd, const char* argv[],
const size_t lens[], size_t argc)
{
conn_->build(cmd, NULL, argv, lens, argc);
if (conn_->get_status("QUEUED") == false)
build(cmd, NULL, argv, lens, argc);
if (check_status("QUEUED") == false)
return false;
cmds_.push_back(cmd);
return true;
@ -91,8 +91,8 @@ bool redis_transaction::run_cmd(const char* cmd, const char* argv[],
bool redis_transaction::run_cmd(const char* cmd,
const std::vector<string>& args)
{
conn_->build(cmd, NULL, args);
if (conn_->get_status("QUEUED") == false)
build(cmd, NULL, args);
if (check_status("QUEUED") == false)
return false;
cmds_.push_back(cmd);
return true;
@ -100,7 +100,7 @@ bool redis_transaction::run_cmd(const char* cmd,
size_t redis_transaction::get_size() const
{
return conn_->get_size();
return result_size();
}
const redis_result* redis_transaction::get_child(size_t i, string* cmd) const
@ -110,7 +110,7 @@ const redis_result* redis_transaction::get_child(size_t i, string* cmd) const
if (i < cmds_.size())
*cmd = cmds_[i];
}
return conn_->get_child(i);
return result_child(i);
}
} // namespace acl

View File

@ -24,11 +24,10 @@ redis_zset::~redis_zset()
int redis_zset::zadd(const char* key, const std::map<string, double>& members)
{
dbuf_pool* pool = conn_->get_pool();
size_t argc = 2 + members.size() * 2;
const char** argv = (const char**)
pool->dbuf_alloc(argc * sizeof(char*));
size_t *lens = (size_t*) pool->dbuf_alloc(argc * sizeof(size_t));
pool_->dbuf_alloc(argc * sizeof(char*));
size_t *lens = (size_t*) pool_->dbuf_alloc(argc * sizeof(size_t));
argv[0] = "ZADD";
lens[0] = sizeof("ZADD") - 1;
@ -41,7 +40,7 @@ int redis_zset::zadd(const char* key, const std::map<string, double>& members)
std::map<string, double>::const_iterator cit = members.begin();
for (; cit != members.end(); ++cit)
{
buf = (char*) pool->dbuf_alloc(BUFLEN);
buf = (char*) pool_->dbuf_alloc(BUFLEN);
safe_snprintf(buf, BUFLEN, "%.8f", cit->second);
argv[i] = buf;
@ -53,18 +52,17 @@ int redis_zset::zadd(const char* key, const std::map<string, double>& members)
i++;
}
conn_->build_request(argc, argv, lens);
return conn_->get_number();
build_request(argc, argv, lens);
return get_number();
}
int redis_zset::zadd(const char* key,
const std::vector<std::pair<string, double> >&members)
{
dbuf_pool* pool = conn_->get_pool();
size_t argc = 2 + members.size() * 2;
const char** argv = (const char**)
pool->dbuf_alloc(argc * sizeof(char*));
size_t* lens = (size_t*) pool->dbuf_alloc(argc * sizeof(size_t));
pool_->dbuf_alloc(argc * sizeof(char*));
size_t* lens = (size_t*) pool_->dbuf_alloc(argc * sizeof(size_t));
argv[0] = "ZADD";
lens[0] = sizeof("ZADD") - 1;
@ -77,7 +75,7 @@ int redis_zset::zadd(const char* key,
std::vector<std::pair<string, double> >::const_iterator cit;
for (cit = members.begin(); cit != members.end(); ++cit)
{
buf = (char*) pool->dbuf_alloc(BUFLEN);
buf = (char*) pool_->dbuf_alloc(BUFLEN);
safe_snprintf(buf, BUFLEN, "%.8f", (*cit).second);
argv[i] = buf;
lens[i] = strlen(buf);
@ -88,18 +86,17 @@ int redis_zset::zadd(const char* key,
i++;
}
conn_->build_request(argc, argv, lens);
return conn_->get_number();
build_request(argc, argv, lens);
return get_number();
}
int redis_zset::zadd(const char* key,
const std::vector<std::pair<const char*, double> >&members)
{
dbuf_pool* pool = conn_->get_pool();
size_t argc = 2 + members.size() * 2;
const char** argv = (const char**)
pool->dbuf_alloc(argc * sizeof(char*));
size_t* lens = (size_t*) pool->dbuf_alloc(argc * sizeof(size_t));
pool_->dbuf_alloc(argc * sizeof(char*));
size_t* lens = (size_t*) pool_->dbuf_alloc(argc * sizeof(size_t));
argv[0] = "ZADD";
lens[0] = sizeof("ZADD") - 1;
@ -113,7 +110,7 @@ int redis_zset::zadd(const char* key,
for (cit = members.begin(); cit != members.end(); ++cit)
{
buf = (char*) pool->dbuf_alloc(BUFLEN);
buf = (char*) pool_->dbuf_alloc(BUFLEN);
safe_snprintf(buf, BUFLEN, "%.8f", (*cit).second);
argv[i] = buf;
lens[i] = strlen(buf);
@ -124,8 +121,8 @@ int redis_zset::zadd(const char* key,
i++;
}
conn_->build_request(argc, argv, lens);
return conn_->get_number();
build_request(argc, argv, lens);
return get_number();
}
int redis_zset::zadd(const char* key, const std::vector<string>& members,
@ -135,11 +132,10 @@ int redis_zset::zadd(const char* key, const std::vector<string>& members,
if (size != members.size())
return -1;
dbuf_pool* pool = conn_->get_pool();
size_t argc = 2 + scores.size() * 2;
const char** argv = (const char**)
pool->dbuf_alloc(argc * sizeof(char*));
size_t* lens = (size_t*) pool->dbuf_alloc(argc * sizeof(size_t));
pool_->dbuf_alloc(argc * sizeof(char*));
size_t* lens = (size_t*) pool_->dbuf_alloc(argc * sizeof(size_t));
argv[0] = "ZADD";
lens[0] = sizeof("ZADD") - 1;
@ -152,7 +148,7 @@ int redis_zset::zadd(const char* key, const std::vector<string>& members,
for (size_t i = 0; i < size; i++)
{
buf = (char*) pool->dbuf_alloc(BUFLEN);
buf = (char*) pool_->dbuf_alloc(BUFLEN);
safe_snprintf(buf, BUFLEN, "%.8f", scores[i]);
argv[j] = buf;
lens[j] = strlen(buf);
@ -163,8 +159,8 @@ int redis_zset::zadd(const char* key, const std::vector<string>& members,
j++;
}
conn_->build_request(argc, argv, lens);
return conn_->get_number();
build_request(argc, argv, lens);
return get_number();
}
int redis_zset::zadd(const char* key, const std::vector<const char*>& members,
@ -174,11 +170,10 @@ int redis_zset::zadd(const char* key, const std::vector<const char*>& members,
if (size != members.size())
return -1;
dbuf_pool* pool = conn_->get_pool();
size_t argc = 2 + scores.size() * 2;
const char** argv = (const char**)
pool->dbuf_alloc(argc * sizeof(char*));
size_t* lens = (size_t*) pool->dbuf_alloc(argc * sizeof(size_t));
pool_->dbuf_alloc(argc * sizeof(char*));
size_t* lens = (size_t*) pool_->dbuf_alloc(argc * sizeof(size_t));
argv[0] = "ZADD";
lens[0] = sizeof("ZADD") - 1;
@ -191,7 +186,7 @@ int redis_zset::zadd(const char* key, const std::vector<const char*>& members,
for (size_t i = 0; i < size; i++)
{
buf = (char*) pool->dbuf_alloc(BUFLEN);
buf = (char*) pool_->dbuf_alloc(BUFLEN);
safe_snprintf(buf, BUFLEN, "%.8f", scores[i]);
argv[j] = buf;
lens[j] = strlen(buf);
@ -202,18 +197,17 @@ int redis_zset::zadd(const char* key, const std::vector<const char*>& members,
j++;
}
conn_->build_request(argc, argv, lens);
return conn_->get_number();
build_request(argc, argv, lens);
return get_number();
}
int redis_zset::zadd(const char* key, const char* members[], double scores[],
size_t size)
{
dbuf_pool* pool = conn_->get_pool();
size_t argc = 2 + size * 2;
const char** argv = (const char**)
pool->dbuf_alloc(argc * sizeof(char*));
size_t* lens = (size_t*) pool->dbuf_alloc(argc * sizeof(size_t));
pool_->dbuf_alloc(argc * sizeof(char*));
size_t* lens = (size_t*) pool_->dbuf_alloc(argc * sizeof(size_t));
argv[0] = "ZADD";
lens[0] = sizeof("ZADD") - 1;
@ -226,7 +220,7 @@ int redis_zset::zadd(const char* key, const char* members[], double scores[],
for (size_t i = 0; i < size; i++)
{
buf = (char*) pool->dbuf_alloc(BUFLEN);
buf = (char*) pool_->dbuf_alloc(BUFLEN);
safe_snprintf(buf, BUFLEN, "%.8f", scores[i]);
argv[j] = buf;
lens[j] = strlen(buf);
@ -237,18 +231,17 @@ int redis_zset::zadd(const char* key, const char* members[], double scores[],
j++;
}
conn_->build_request(argc, argv, lens);
return conn_->get_number();
build_request(argc, argv, lens);
return get_number();
}
int redis_zset::zadd(const char* key, const char* members[],
size_t members_len[], double scores[], size_t size)
{
dbuf_pool* pool = conn_->get_pool();
size_t argc = 2 + size * 2;
const char** argv = (const char**)
pool->dbuf_alloc(argc * sizeof(char*));
size_t* lens = (size_t*) pool->dbuf_alloc(argc * sizeof(size_t));
pool_->dbuf_alloc(argc * sizeof(char*));
size_t* lens = (size_t*) pool_->dbuf_alloc(argc * sizeof(size_t));
argv[0] = "ZADD";
lens[0] = sizeof("ZADD") - 1;
@ -262,7 +255,7 @@ int redis_zset::zadd(const char* key, const char* members[],
for (size_t i = 0; i < size; i++)
{
buf = (char*) pool->dbuf_alloc(BUFLEN);
buf = (char*) pool_->dbuf_alloc(BUFLEN);
len = safe_snprintf(buf, BUFLEN, "%.8f", scores[i]);
argv[j] = buf;
lens[j] = len;
@ -273,8 +266,8 @@ int redis_zset::zadd(const char* key, const char* members[],
j++;
}
conn_->build_request(argc, argv, lens);
return conn_->get_number();
build_request(argc, argv, lens);
return get_number();
}
int redis_zset::zcard(const char* key)
@ -288,8 +281,8 @@ int redis_zset::zcard(const char* key)
argv[1] = key;
lens[1] = strlen(key);
conn_->build_request(2, argv, lens);
return conn_->get_number();
build_request(2, argv, lens);
return get_number();
}
int redis_zset::zcount(const char* key, double min, double max)
@ -313,8 +306,8 @@ int redis_zset::zcount(const char* key, double min, double max)
argv[3] = max_buf;
lens[3] = strlen(max_buf);
conn_->build_request(4, argv, lens);
return conn_->get_number();
build_request(4, argv, lens);
return get_number();
}
bool redis_zset::zincrby(const char* key, double inc,
@ -343,8 +336,8 @@ bool redis_zset::zincrby(const char* key, double inc,
argv[3] = member;
lens[3] = len;
conn_->build_request(4, argv, lens);
int ret = conn_->get_string(score, sizeof(score));
build_request(4, argv, lens);
int ret = get_string(score, sizeof(score));
if (ret < 0)
return false;
if (result)
@ -374,8 +367,8 @@ int redis_zset::zrange_get(const char* cmd, const char* key, int start,
argv[3] = stop_s;
lens[3] = strlen(stop_s);
conn_->build_request(4, argv, lens);
return conn_->get_strings(result);
build_request(4, argv, lens);
return get_strings(result);
}
int redis_zset::zrange(const char* key, int start,
@ -411,8 +404,8 @@ int redis_zset::zrange_get_with_scores(const char* cmd, const char* key,
argv[4] = "WITHSCORES";
lens[4] = sizeof("WITHSCORES") - 1;
conn_->build_request(5, argv, lens);
const redis_result* result = conn_->run();
build_request(5, argv, lens);
const redis_result* result = run();
if (result == NULL || result->get_type() != REDIS_RESULT_ARRAY)
return -1;
@ -495,8 +488,8 @@ int redis_zset::zrangebyscore_get(const char* cmd, const char* key,
argc += 2;
}
conn_->build_request(argc, argv, lens);
return conn_->get_strings(out);
build_request(argc, argv, lens);
return get_strings(out);
}
int redis_zset::zrangebyscore(const char* key, const char* min,
@ -560,8 +553,8 @@ int redis_zset::zrangebyscore_get_with_scores(const char* cmd,
argc += 2;
}
conn_->build_request(argc, argv, lens);
const redis_result* result = conn_->run();
build_request(argc, argv, lens);
const redis_result* result = run();
if (result == NULL || result->get_type() != REDIS_RESULT_ARRAY)
return -1;
@ -634,8 +627,8 @@ int redis_zset::zrank(const char* key, const char* member, size_t len)
argv[2] = member;
lens[2] = len;
conn_->build_request(3, argv, lens);
return conn_->get_number();
build_request(3, argv, lens);
return get_number();
}
int redis_zset::zrank(const char* key, const char* member)
@ -658,21 +651,21 @@ int redis_zset::zrem(const char* key, const char* first_member, ...)
int redis_zset::zrem(const char* key, const std::vector<string>& members)
{
conn_->build("ZREM", key, members);
return conn_->get_number();
build("ZREM", key, members);
return get_number();
}
int redis_zset::zrem(const char* key, const std::vector<const char*>& members)
{
conn_->build("ZREM", key, members);
return conn_->get_number();
build("ZREM", key, members);
return get_number();
}
int redis_zset::zrem(const char* key, const char* members[],
const size_t lens[], size_t argc)
{
conn_->build("ZREM", key, members, lens, argc);
return conn_->get_number();
build("ZREM", key, members, lens, argc);
return get_number();
}
int redis_zset::zremrangebyrank(const char* key, int start, int stop)
@ -696,8 +689,8 @@ int redis_zset::zremrangebyrank(const char* key, int start, int stop)
argv[3] = stop_s;
lens[3] = strlen(stop_s);
conn_->build_request(4, argv, lens);
return conn_->get_number();
build_request(4, argv, lens);
return get_number();
}
int redis_zset::zremrangebyscore(const char* key, double min, double max)
@ -727,8 +720,8 @@ int redis_zset::zremrangebyscore(const char* key, const char* min,
argv[3] = max;
lens[3] = strlen(max);
conn_->build_request(4, argv, lens);
return conn_->get_number();
build_request(4, argv, lens);
return get_number();
}
int redis_zset::zrevrange(const char* key, int start, int stop,
@ -776,8 +769,8 @@ int redis_zset::zrevrank(const char* key, const char* member, size_t len)
argv[2] = member;
lens[2] = len;
conn_->build_request(3, argv, lens);
return conn_->get_number();
build_request(3, argv, lens);
return get_number();
}
int redis_zset::zrevrank(const char* key, const char* member)
@ -800,10 +793,10 @@ bool redis_zset::zscore(const char* key, const char* member, size_t len,
argv[2] = member;
lens[2] = len;
conn_->build_request(3, argv, lens);
build_request(3, argv, lens);
char buf[BUFLEN];
int ret = conn_->get_string(buf, sizeof(buf));
int ret = get_string(buf, sizeof(buf));
if (ret <= 0)
return false;
result = atof(buf);
@ -822,13 +815,11 @@ int redis_zset::zstore(const char* cmd, const char* dst,
if (num == 0)
return -1;
dbuf_pool* pool = conn_->get_pool();
size_t argc = num * 2 + 6;
const char** argv = (const char**)
pool->dbuf_alloc(argc * sizeof(char*));
size_t* lens = (size_t*) pool->dbuf_alloc(argc * sizeof(size_t));
pool_->dbuf_alloc(argc * sizeof(char*));
size_t* lens = (size_t*) pool_->dbuf_alloc(argc * sizeof(size_t));
argv[0] = cmd;
lens[0] = strlen(cmd);
@ -856,7 +847,7 @@ int redis_zset::zstore(const char* cmd, const char* dst,
char* buf;
for (cit = keys.begin(); cit != keys.end(); ++cit)
{
buf = (char*) pool->dbuf_alloc(BUFLEN);
buf = (char*) pool_->dbuf_alloc(BUFLEN);
safe_snprintf(buf, BUFLEN, "%.8f", cit->second);
argv[i] = buf;
@ -876,8 +867,8 @@ int redis_zset::zstore(const char* cmd, const char* dst,
acl_assert(i == argc);
conn_->build_request(argc, argv, lens);
return conn_->get_number();
build_request(argc, argv, lens);
return get_number();
}
int redis_zset::zunionstore(const char* dst,
@ -907,10 +898,9 @@ int redis_zset::zstore(const char* cmd, const char* dst,
if (aggregate != NULL || *aggregate != 0)
argc += 2;
dbuf_pool* pool = conn_->get_pool();
const char** argv = (const char**)
pool->dbuf_alloc(argc * sizeof(char*));
size_t* lens = (size_t*) pool->dbuf_alloc(argc * sizeof(size_t));
pool_->dbuf_alloc(argc * sizeof(char*));
size_t* lens = (size_t*) pool_->dbuf_alloc(argc * sizeof(size_t));
argv[0] = cmd;
lens[0] = strlen(cmd);
@ -942,7 +932,7 @@ int redis_zset::zstore(const char* cmd, const char* dst,
std::vector<double>::const_iterator cit2 = weights->begin();
for (; cit2 != weights->end(); ++cit2)
{
score = (char*) pool->dbuf_alloc(BUFLEN);
score = (char*) pool_->dbuf_alloc(BUFLEN);
safe_snprintf(score, BUFLEN, "%.8f", *cit2);
argv[i] = score;
lens[i] = strlen(score);
@ -963,8 +953,8 @@ int redis_zset::zstore(const char* cmd, const char* dst,
acl_assert(i == argc);
conn_->build_request(argc, argv, lens);
return conn_->get_number();
build_request(argc, argv, lens);
return get_number();
}
int redis_zset::zunionstore(const char* dst, const std::vector<string>& keys,
@ -1012,8 +1002,8 @@ int redis_zset::zrangebylex(const char* key, const char* min, const char* max,
argc++;
}
conn_->build_request(argc, argv, lens);
return conn_->get_strings(out);
build_request(argc, argv, lens);
return get_strings(out);
}
int redis_zset::zlexcount(const char* key, const char* min, const char* max)
@ -1033,8 +1023,8 @@ int redis_zset::zlexcount(const char* key, const char* min, const char* max)
argv[3] = max;
lens[3] = strlen(max);
conn_->build_request(4, argv, lens);
return conn_->get_number();
build_request(4, argv, lens);
return get_number();
}
int redis_zset::zremrangebylex(const char* key, const char* min, const char* max)
@ -1054,8 +1044,8 @@ int redis_zset::zremrangebylex(const char* key, const char* min, const char* max
argv[3] = max;
lens[3] = strlen(max);
conn_->build_request(4, argv, lens);
return conn_->get_number();
build_request(4, argv, lens);
return get_number();
}
int redis_zset::zscan(const char* key, int cursor,