From 1cc7e646af8d01145df3aa1012903553194556df Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 28 Oct 2013 11:32:34 +0100 Subject: [PATCH] HSCAN implemented. --- src/db.c | 2 +- src/redis.c | 1 + src/redis.h | 1 + src/t_hash.c | 8 ++++++++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/db.c b/src/db.c index 402ad378..1c91c3c1 100644 --- a/src/db.c +++ b/src/db.c @@ -459,7 +459,7 @@ void scanGenericCommand(redisClient *c, robj *o) { listAddNodeTail(keys, (vstr != NULL) ? createStringObject((char*)vstr,vlen) : createStringObjectFromLongLong(vll)); - ziplistNext(o->ptr,p); + p = ziplistNext(o->ptr,p); } } else { redisPanic("Not handled encoding in SCAN."); diff --git a/src/redis.c b/src/redis.c index a425be08..649c7766 100644 --- a/src/redis.c +++ b/src/redis.c @@ -192,6 +192,7 @@ struct redisCommand redisCommandTable[] = { {"hvals",hvalsCommand,2,"rS",0,NULL,1,1,1,0,0}, {"hgetall",hgetallCommand,2,"r",0,NULL,1,1,1,0,0}, {"hexists",hexistsCommand,3,"r",0,NULL,1,1,1,0,0}, + {"hscan",hscanCommand,-3,"rR",0,NULL,1,1,1,0,0}, {"incrby",incrbyCommand,3,"wm",0,NULL,1,1,1,0,0}, {"decrby",decrbyCommand,3,"wm",0,NULL,1,1,1,0,0}, {"incrbyfloat",incrbyfloatCommand,3,"wm",0,NULL,1,1,1,0,0}, diff --git a/src/redis.h b/src/redis.h index 7ba36609..16ec5ae8 100644 --- a/src/redis.h +++ b/src/redis.h @@ -1308,6 +1308,7 @@ void hkeysCommand(redisClient *c); void hvalsCommand(redisClient *c); void hgetallCommand(redisClient *c); void hexistsCommand(redisClient *c); +void hscanCommand(redisClient *c); void configCommand(redisClient *c); void hincrbyCommand(redisClient *c); void hincrbyfloatCommand(redisClient *c); diff --git a/src/t_hash.c b/src/t_hash.c index 959c9ca8..0c5e7af7 100644 --- a/src/t_hash.c +++ b/src/t_hash.c @@ -762,3 +762,11 @@ void hexistsCommand(redisClient *c) { addReply(c, hashTypeExists(o,c->argv[2]) ? shared.cone : shared.czero); } + +void hscanCommand(redisClient *c) { + robj *o; + + if ((o= lookupKeyReadOrReply(c,c->argv[1],shared.emptyscan)) == NULL || + checkType(c,o,REDIS_HASH)) return; + scanGenericCommand(c,o); +} -- GitLab