fixed bug for redis scan in class redis_command/redis_key/redis_hash/redis_set/redis_zset

This commit is contained in:
ubuntu14 2015-08-24 07:12:15 -07:00
parent bc119e8199
commit bfebe1b5d3
9 changed files with 14 additions and 10 deletions

View File

@ -1,6 +1,10 @@
修改历史列表:
------------------------------------------------------------------------
349) 2015.8.24
349.1) bugfix: redis_command/redis_key/redis_hash/redis_set/redis_zset 在
遍历过程中,可能服务端会返回 cursor 为 > 0 但结果集为空的情况,需要对这种情况进行处理
348) 2015.8.20
348.1) compile: zlib_stream 类内部使用了动态加载 zlib 库的方式。

View File

@ -321,7 +321,7 @@ public:
* scan finish
* -1: ³ö´í
* some error happened
* >0:
* >0: 使 out
* the next cursor postion to scan
*/
int hscan(const char* key, int cursor, std::map<string, string>& out,

View File

@ -390,7 +390,7 @@ public:
* iterating is finished
* -1: ³ö´í
* some error happened
* >0:
* >0: 使 out
* the next cursor value for iterating
*/
int scan(int cursor, std::vector<string>& out,

View File

@ -346,7 +346,7 @@ public:
* scan finish
* -1: ³ö´í
* some error happened
* >0:
* >0: 使 out
* the next cursor postion to scan
*/
int sscan(const char* key, int cursor, std::vector<string>& out,

View File

@ -469,7 +469,7 @@ public:
* @return {int}
* 0
* -1:
* >0:
* >0: 使 out
*/
int zscan(const char* key, int cursor,
std::vector<std::pair<string, double> >& out,

View File

@ -19,7 +19,7 @@ int main(int argc, char* argv[])
if (argc >= 2 && strcmp(argv[1], "alone") == 0)
{
acl::log::stdout_open(true); // 日志输出至标准输出
const char* addr = "127.0.0.1:8888, 127.0.0.1:8889";
const char* addr = ":8888, 127.0.0.1:8889";
printf("bind on: %s\r\n", addr);
ms.run_alone(addr, NULL, 0); // 单独运行方式
}

View File

@ -54,8 +54,8 @@ void master_service::on_read(acl::socket_stream* stream)
logger_error("write to %s error %s",
stream->get_peer(true), acl::last_serror());
if (0)
logger(">>Peer: %s, Local: %s", stream->get_peer(true),
stream->get_local(true));
logger(">>Peer: %s, Local: %s", stream->get_peer(true),
stream->get_local(true));
}
void master_service::proc_on_init()

View File

@ -24,7 +24,7 @@ static void run(void)
else
stream.set_peer(__server_addr);
stream.set_rw_timeout(0);
stream.set_rw_timeout(1);
// 分配内存
buf = (char*) malloc(__dat_length + 1);
@ -57,7 +57,7 @@ static void run(void)
break;
}
if (i == 0)
if (i % 1000 == 0)
{
res[ret] = 0;
printf("read >>> %s\r\n", res);

View File

@ -1122,7 +1122,7 @@ const redis_result** redis_command::scan_keys(const char* cmd, const char* key,
const redis_result** children = rr->get_children(&size);
if (children == NULL)
{
cursor = 0;
//cursor = 0;
size = 0;
}