mirror of
https://github.com/fluencelabs/redis
synced 2025-04-05 09:11:03 +00:00
Use existing reply functions where possible
This commit is contained in:
parent
cd76bb651d
commit
b70d355521
6
src/db.c
6
src/db.c
@ -245,13 +245,11 @@ void keysCommand(redisClient *c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void dbsizeCommand(redisClient *c) {
|
void dbsizeCommand(redisClient *c) {
|
||||||
addReplySds(c,
|
addReplyLongLong(c,dictSize(c->db->dict));
|
||||||
sdscatprintf(sdsempty(),":%lu\r\n",dictSize(c->db->dict)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void lastsaveCommand(redisClient *c) {
|
void lastsaveCommand(redisClient *c) {
|
||||||
addReplySds(c,
|
addReplyLongLong(c,server.lastsave);
|
||||||
sdscatprintf(sdsempty(),":%lu\r\n",server.lastsave));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void typeCommand(redisClient *c) {
|
void typeCommand(redisClient *c) {
|
||||||
|
@ -369,7 +369,7 @@ void sortCommand(redisClient *c) {
|
|||||||
* replaced. */
|
* replaced. */
|
||||||
server.dirty += 1+outputlen;
|
server.dirty += 1+outputlen;
|
||||||
touchWatchedKey(c->db,storekey);
|
touchWatchedKey(c->db,storekey);
|
||||||
addReplySds(c,sdscatprintf(sdsempty(),":%d\r\n",outputlen));
|
addReplyLongLong(c,outputlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Cleanup */
|
/* Cleanup */
|
||||||
|
@ -346,7 +346,7 @@ void hlenCommand(redisClient *c) {
|
|||||||
if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.czero)) == NULL ||
|
if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.czero)) == NULL ||
|
||||||
checkType(c,o,REDIS_HASH)) return;
|
checkType(c,o,REDIS_HASH)) return;
|
||||||
|
|
||||||
addReplyUlong(c,hashTypeLength(o));
|
addReplyLongLong(c,hashTypeLength(o));
|
||||||
}
|
}
|
||||||
|
|
||||||
void genericHgetallCommand(redisClient *c, int flags) {
|
void genericHgetallCommand(redisClient *c, int flags) {
|
||||||
|
@ -342,7 +342,7 @@ void pushxGenericCommand(redisClient *c, robj *refval, robj *val, int where) {
|
|||||||
server.dirty++;
|
server.dirty++;
|
||||||
}
|
}
|
||||||
|
|
||||||
addReplyUlong(c,listTypeLength(subject));
|
addReplyLongLong(c,listTypeLength(subject));
|
||||||
}
|
}
|
||||||
|
|
||||||
void lpushxCommand(redisClient *c) {
|
void lpushxCommand(redisClient *c) {
|
||||||
@ -366,7 +366,7 @@ void linsertCommand(redisClient *c) {
|
|||||||
void llenCommand(redisClient *c) {
|
void llenCommand(redisClient *c) {
|
||||||
robj *o = lookupKeyReadOrReply(c,c->argv[1],shared.czero);
|
robj *o = lookupKeyReadOrReply(c,c->argv[1],shared.czero);
|
||||||
if (o == NULL || checkType(c,o,REDIS_LIST)) return;
|
if (o == NULL || checkType(c,o,REDIS_LIST)) return;
|
||||||
addReplyUlong(c,listTypeLength(o));
|
addReplyLongLong(c,listTypeLength(o));
|
||||||
}
|
}
|
||||||
|
|
||||||
void lindexCommand(redisClient *c) {
|
void lindexCommand(redisClient *c) {
|
||||||
@ -594,7 +594,7 @@ void lremCommand(redisClient *c) {
|
|||||||
decrRefCount(obj);
|
decrRefCount(obj);
|
||||||
|
|
||||||
if (listTypeLength(subject) == 0) dbDelete(c->db,c->argv[1]);
|
if (listTypeLength(subject) == 0) dbDelete(c->db,c->argv[1]);
|
||||||
addReplySds(c,sdscatprintf(sdsempty(),":%d\r\n",removed));
|
addReplyLongLong(c,removed);
|
||||||
if (removed) touchWatchedKey(c->db,c->argv[1]);
|
if (removed) touchWatchedKey(c->db,c->argv[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,7 +276,7 @@ void scardCommand(redisClient *c) {
|
|||||||
if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.czero)) == NULL ||
|
if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.czero)) == NULL ||
|
||||||
checkType(c,o,REDIS_SET)) return;
|
checkType(c,o,REDIS_SET)) return;
|
||||||
|
|
||||||
addReplyUlong(c,setTypeSize(o));
|
addReplyLongLong(c,setTypeSize(o));
|
||||||
}
|
}
|
||||||
|
|
||||||
void spopCommand(redisClient *c) {
|
void spopCommand(redisClient *c) {
|
||||||
|
@ -211,7 +211,7 @@ void appendCommand(redisClient *c) {
|
|||||||
}
|
}
|
||||||
touchWatchedKey(c->db,c->argv[1]);
|
touchWatchedKey(c->db,c->argv[1]);
|
||||||
server.dirty++;
|
server.dirty++;
|
||||||
addReplySds(c,sdscatprintf(sdsempty(),":%lu\r\n",(unsigned long)totlen));
|
addReplyLongLong(c,totlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void substrCommand(redisClient *c) {
|
void substrCommand(redisClient *c) {
|
||||||
|
@ -930,7 +930,7 @@ void zcardCommand(redisClient *c) {
|
|||||||
checkType(c,o,REDIS_ZSET)) return;
|
checkType(c,o,REDIS_ZSET)) return;
|
||||||
|
|
||||||
zs = o->ptr;
|
zs = o->ptr;
|
||||||
addReplyUlong(c,zs->zsl->length);
|
addReplyLongLong(c,zs->zsl->length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void zscoreCommand(redisClient *c) {
|
void zscoreCommand(redisClient *c) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user