From 2c643ffa8d08daa06dd7abc7a07223851115a58a Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 28 Oct 2013 11:36:42 +0100 Subject: [PATCH] ZSCAN implemented. --- src/redis.c | 1 + src/redis.h | 1 + src/t_zset.c | 8 ++++++++ 3 files changed, 10 insertions(+) diff --git a/src/redis.c b/src/redis.c index f44c9908d..7932824e7 100644 --- a/src/redis.c +++ b/src/redis.c @@ -182,6 +182,7 @@ struct redisCommand redisCommandTable[] = { {"zscore",zscoreCommand,3,"r",0,NULL,1,1,1,0,0}, {"zrank",zrankCommand,3,"r",0,NULL,1,1,1,0,0}, {"zrevrank",zrevrankCommand,3,"r",0,NULL,1,1,1,0,0}, + {"zscan",zscanCommand,-3,"rR",0,NULL,1,1,1,0,0}, {"hset",hsetCommand,4,"wm",0,NULL,1,1,1,0,0}, {"hsetnx",hsetnxCommand,4,"wm",0,NULL,1,1,1,0,0}, {"hget",hgetCommand,3,"r",0,NULL,1,1,1,0,0}, diff --git a/src/redis.h b/src/redis.h index 55c3ea77c..4312b3421 100644 --- a/src/redis.h +++ b/src/redis.h @@ -1340,6 +1340,7 @@ void hlenCommand(redisClient *c); void zremrangebyrankCommand(redisClient *c); void zunionstoreCommand(redisClient *c); void zinterstoreCommand(redisClient *c); +void zscanCommand(redisClient *c); void hkeysCommand(redisClient *c); void hvalsCommand(redisClient *c); void hgetallCommand(redisClient *c); diff --git a/src/t_zset.c b/src/t_zset.c index 1fcfd6bb6..9d3a79026 100644 --- a/src/t_zset.c +++ b/src/t_zset.c @@ -2207,3 +2207,11 @@ void zrankCommand(redisClient *c) { void zrevrankCommand(redisClient *c) { zrankGenericCommand(c, 1); } + +void zscanCommand(redisClient *c) { + robj *o; + + if ((o= lookupKeyReadOrReply(c,c->argv[1],shared.emptyscan)) == NULL || + checkType(c,o,REDIS_ZSET)) return; + scanGenericCommand(c,o); +}