Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
520b5a33
Commit
520b5a33
authored
Mar 04, 2010
by
antirez
Browse files
Now list push commands return the length of the new list, thanks to Gustavo Picon
parent
8fe7fad7
Changes
2
Hide whitespace changes
Inline
Side-by-side
redis.c
View file @
520b5a33
...
...
@@ -4075,7 +4075,7 @@ static void pushGenericCommand(redisClient *c, int where) {
lobj = lookupKeyWrite(c->db,c->argv[1]);
if (lobj == NULL) {
if (handleClientsWaitingListPush(c,c->argv[1],c->argv[2])) {
addReply(c,shared.
ok
);
addReply(c,shared.
cone
);
return;
}
lobj = createListObject();
...
...
@@ -4094,7 +4094,7 @@ static void pushGenericCommand(redisClient *c, int where) {
return;
}
if (handleClientsWaitingListPush(c,c->argv[1],c->argv[2])) {
addReply(c,shared.
ok
);
addReply(c,shared.
cone
);
return;
}
list = lobj->ptr;
...
...
@@ -4106,7 +4106,7 @@ static void pushGenericCommand(redisClient *c, int where) {
incrRefCount(c->argv[2]);
}
server.dirty++;
addReply(c,s
hared.ok
);
addReply
Sds
(c,s
dscatprintf(sdsempty(),":%d\r\n",listLength(list))
);
}
static void lpushCommand(redisClient *c) {
...
...
test-redis.tcl
View file @
520b5a33
...
...
@@ -406,15 +406,20 @@ proc main {server port} {
}
{
1
}
test
{
Basic LPUSH, RPUSH, LLENGTH, LINDEX
}
{
$r lpush mylist a
$r lpush mylist b
$r rpush mylist c
set res
[
$r
llen mylist
]
set res
[
$r
lpush mylist a
]
append res
[
$r
lpush mylist b
]
append res
[
$r
rpush mylist c
]
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 1
]
append res
[
$r
lindex mylist 2
]
append res
[
$r
lindex anotherlist 0
]
append res
[
$r
lindex anotherlist 1
]
list $res
[
$r
lindex mylist 100
]
}
{
3
bac
{}}
}
{
1233122
bac
ed
{}}
test
{
DEL a list
}
{
$r del mylist
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment