* For now only the last argument gets integer encoded, so make sure that: 1) every multi bulk commands implemented will have the last arg that is indeed a value, and not used otherwise. 2) to explicitly call the function to encode the object in MSET and other commands where there are multiple "values".
* Man pages for MSET MSETNX and SRANDMEMBER.
* Hashes (HSET, HGET, HEXISTS, HLEN, ...).
-* ZSETs
+* ZSETs: ZADD, ZRANGE, ZDEL, ZINCRBY, ZSCORE.
* An utility able to export an .rdb file into a text-only JSON dump, we can't live anymore without such a tool. Probably an extension to redis-cli.
After 1.1 todo
{"sdiffstore",-3,REDIS_CMD_INLINE},
{"smembers",2,REDIS_CMD_INLINE},
{"zadd",4,REDIS_CMD_BULK},
+ {"zrem",3,REDIS_CMD_BULK},
{"zrange",4,REDIS_CMD_INLINE},
{"zlen",2,REDIS_CMD_INLINE},
{"incrby",3,REDIS_CMD_INLINE},
static void zaddCommand(redisClient *c);
static void zrangeCommand(redisClient *c);
static void zlenCommand(redisClient *c);
+static void zremCommand(redisClient *c);
/*================================= Globals ================================= */
{"sdiffstore",sdiffstoreCommand,-3,REDIS_CMD_INLINE|REDIS_CMD_DENYOOM},
{"smembers",sinterCommand,2,REDIS_CMD_INLINE},
{"zadd",zaddCommand,4,REDIS_CMD_BULK|REDIS_CMD_DENYOOM},
+ {"zrem",zremCommand,3,REDIS_CMD_BULK},
{"zrange",zrangeCommand,4,REDIS_CMD_INLINE},
{"zlen",zlenCommand,2,REDIS_CMD_INLINE},
{"incrby",incrbyCommand,3,REDIS_CMD_INLINE|REDIS_CMD_DENYOOM},
}
}
+static void zremCommand(redisClient *c) {
+ robj *zsetobj;
+ zset *zs;
+
+ zsetobj = lookupKeyWrite(c->db,c->argv[1]);
+ if (zsetobj == NULL) {
+ addReply(c,shared.czero);
+ } else {
+ dictEntry *de;
+ double *oldscore;
+ int deleted;
+
+ if (zsetobj->type != REDIS_ZSET) {
+ addReply(c,shared.wrongtypeerr);
+ return;
+ }
+ zs = zsetobj->ptr;
+ de = dictFind(zs->dict,c->argv[2]);
+ if (de == NULL) {
+ addReply(c,shared.czero);
+ return;
+ }
+ /* Delete from the skiplist */
+ oldscore = dictGetEntryVal(de);
+ deleted = zslDelete(zs->zsl,*oldscore,c->argv[2]);
+ assert(deleted != 0);
+
+ /* Delete from the hash table */
+ dictDelete(zs->dict,c->argv[2]);
+ if (htNeedsResize(zs->dict)) dictResize(zs->dict);
+ server.dirty++;
+ addReply(c,shared.cone);
+ }
+}
+
static void zrangeCommand(redisClient *c) {
robj *o;
int start = atoi(c->argv[2]->ptr);
{"createZsetObject",(unsigned long)createZsetObject},
{"zaddCommand",(unsigned long)zaddCommand},
{"zrangeCommand",(unsigned long)zrangeCommand},
+{"zremCommand",(unsigned long)zremCommand},
{NULL,0}
};