Merge pull request #2415 from landmime/unstable

added a new hvstrlen command
This commit is contained in:
Salvatore Sanfilippo
2015-02-27 15:24:04 +01:00
4 changed files with 47 additions and 0 deletions

View File

@ -202,6 +202,7 @@ struct redisCommand redisCommandTable[] = {
{"hincrbyfloat",hincrbyfloatCommand,4,"wmF",0,NULL,1,1,1,0,0},
{"hdel",hdelCommand,-3,"wF",0,NULL,1,1,1,0,0},
{"hlen",hlenCommand,2,"rF",0,NULL,1,1,1,0,0},
{"hvstrlen",hvstrlenCommand,3,"rF",0,NULL,1,1,1,0,0},
{"hkeys",hkeysCommand,2,"rS",0,NULL,1,1,1,0,0},
{"hvals",hvalsCommand,2,"rS",0,NULL,1,1,1,0,0},
{"hgetall",hgetallCommand,2,"r",0,NULL,1,1,1,0,0},

View File

@ -1516,6 +1516,7 @@ void hmsetCommand(redisClient *c);
void hmgetCommand(redisClient *c);
void hdelCommand(redisClient *c);
void hlenCommand(redisClient *c);
void hvstrlenCommand(redisClient *c);
void zremrangebyrankCommand(redisClient *c);
void zunionstoreCommand(redisClient *c);
void zinterstoreCommand(redisClient *c);

View File

@ -685,6 +685,20 @@ void hlenCommand(redisClient *c) {
addReplyLongLong(c,hashTypeLength(o));
}
void hvstrlenCommand(redisClient *c) {
robj *o;
robj *value;
if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.nullbulk)) == NULL ||
checkType(c,o,REDIS_HASH)) return;
if ((value = hashTypeGetObject(o,c->argv[2])) == NULL) {
addReply(c, shared.nullbulk);
} else {
addReplyLongLong(c,stringObjectLen(value));
decrRefCount(value);
}
}
static void addHashIteratorCursorToReply(redisClient *c, hashTypeIterator *hi, int what) {
if (hi->encoding == REDIS_ENCODING_ZIPLIST) {
unsigned char *vstr = NULL;