mirror of
https://github.com/fluencelabs/redis
synced 2025-03-31 23:01:03 +00:00
Now list push commands return the length of the new list, thanks to Gustavo Picon
This commit is contained in:
parent
8fe7fad771
commit
520b5a33ae
6
redis.c
6
redis.c
@ -4075,7 +4075,7 @@ static void pushGenericCommand(redisClient *c, int where) {
|
|||||||
lobj = lookupKeyWrite(c->db,c->argv[1]);
|
lobj = lookupKeyWrite(c->db,c->argv[1]);
|
||||||
if (lobj == NULL) {
|
if (lobj == NULL) {
|
||||||
if (handleClientsWaitingListPush(c,c->argv[1],c->argv[2])) {
|
if (handleClientsWaitingListPush(c,c->argv[1],c->argv[2])) {
|
||||||
addReply(c,shared.ok);
|
addReply(c,shared.cone);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lobj = createListObject();
|
lobj = createListObject();
|
||||||
@ -4094,7 +4094,7 @@ static void pushGenericCommand(redisClient *c, int where) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (handleClientsWaitingListPush(c,c->argv[1],c->argv[2])) {
|
if (handleClientsWaitingListPush(c,c->argv[1],c->argv[2])) {
|
||||||
addReply(c,shared.ok);
|
addReply(c,shared.cone);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
list = lobj->ptr;
|
list = lobj->ptr;
|
||||||
@ -4106,7 +4106,7 @@ static void pushGenericCommand(redisClient *c, int where) {
|
|||||||
incrRefCount(c->argv[2]);
|
incrRefCount(c->argv[2]);
|
||||||
}
|
}
|
||||||
server.dirty++;
|
server.dirty++;
|
||||||
addReply(c,shared.ok);
|
addReplySds(c,sdscatprintf(sdsempty(),":%d\r\n",listLength(list)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lpushCommand(redisClient *c) {
|
static void lpushCommand(redisClient *c) {
|
||||||
|
@ -406,15 +406,20 @@ proc main {server port} {
|
|||||||
} {1}
|
} {1}
|
||||||
|
|
||||||
test {Basic LPUSH, RPUSH, LLENGTH, LINDEX} {
|
test {Basic LPUSH, RPUSH, LLENGTH, LINDEX} {
|
||||||
$r lpush mylist a
|
set res [$r lpush mylist a]
|
||||||
$r lpush mylist b
|
append res [$r lpush mylist b]
|
||||||
$r rpush mylist c
|
append res [$r rpush mylist c]
|
||||||
set res [$r llen mylist]
|
append res [$r llen mylist]
|
||||||
|
append res [$r rpush anotherlist d]
|
||||||
|
append res [$r lpush anotherlist e]
|
||||||
|
append res [$r llen anotherlist]
|
||||||
append res [$r lindex mylist 0]
|
append res [$r lindex mylist 0]
|
||||||
append res [$r lindex mylist 1]
|
append res [$r lindex mylist 1]
|
||||||
append res [$r lindex mylist 2]
|
append res [$r lindex mylist 2]
|
||||||
|
append res [$r lindex anotherlist 0]
|
||||||
|
append res [$r lindex anotherlist 1]
|
||||||
list $res [$r lindex mylist 100]
|
list $res [$r lindex mylist 100]
|
||||||
} {3bac {}}
|
} {1233122baced {}}
|
||||||
|
|
||||||
test {DEL a list} {
|
test {DEL a list} {
|
||||||
$r del mylist
|
$r del mylist
|
||||||
|
Loading…
x
Reference in New Issue
Block a user