mirror of
https://github.com/fluencelabs/redis
synced 2025-03-18 16:40:50 +00:00
make RPUSHX and LPUSHX variadic
This commit is contained in:
parent
b670a16282
commit
d88c3c77be
@ -145,8 +145,8 @@ struct redisCommand redisCommandTable[] = {
|
||||
{"mget",mgetCommand,-2,"r",0,NULL,1,-1,1,0,0},
|
||||
{"rpush",rpushCommand,-3,"wmF",0,NULL,1,1,1,0,0},
|
||||
{"lpush",lpushCommand,-3,"wmF",0,NULL,1,1,1,0,0},
|
||||
{"rpushx",rpushxCommand,3,"wmF",0,NULL,1,1,1,0,0},
|
||||
{"lpushx",lpushxCommand,3,"wmF",0,NULL,1,1,1,0,0},
|
||||
{"rpushx",rpushxCommand,-3,"wmF",0,NULL,1,1,1,0,0},
|
||||
{"lpushx",lpushxCommand,-3,"wmF",0,NULL,1,1,1,0,0},
|
||||
{"linsert",linsertCommand,5,"wm",0,NULL,1,1,1,0,0},
|
||||
{"rpop",rpopCommand,2,"wF",0,NULL,1,1,1,0,0},
|
||||
{"lpop",lpopCommand,2,"wF",0,NULL,1,1,1,0,0},
|
||||
|
19
src/t_list.c
19
src/t_list.c
@ -233,19 +233,26 @@ void rpushCommand(client *c) {
|
||||
}
|
||||
|
||||
void pushxGenericCommand(client *c, int where) {
|
||||
int j, pushed = 0;
|
||||
robj *subject;
|
||||
|
||||
if ((subject = lookupKeyWriteOrReply(c,c->argv[1],shared.czero)) == NULL ||
|
||||
checkType(c,subject,OBJ_LIST)) return;
|
||||
|
||||
char *event = (where == LIST_HEAD) ? "lpush" : "rpush";
|
||||
c->argv[2] = tryObjectEncoding(c->argv[2]);
|
||||
listTypePush(subject,c->argv[2],where);
|
||||
signalModifiedKey(c->db,c->argv[1]);
|
||||
notifyKeyspaceEvent(NOTIFY_LIST,event,c->argv[1],c->db->id);
|
||||
server.dirty++;
|
||||
for (j = 2; j < c->argc; j++) {
|
||||
c->argv[j] = tryObjectEncoding(c->argv[j]);
|
||||
listTypePush(subject,c->argv[j],where);
|
||||
pushed++;
|
||||
}
|
||||
|
||||
addReplyLongLong(c,listTypeLength(subject));
|
||||
|
||||
if (pushed) {
|
||||
char *event = (where == LIST_HEAD) ? "lpush" : "rpush";
|
||||
signalModifiedKey(c->db,c->argv[1]);
|
||||
notifyKeyspaceEvent(NOTIFY_LIST,event,c->argv[1],c->db->id);
|
||||
}
|
||||
server.dirty += pushed;
|
||||
}
|
||||
|
||||
void lpushxCommand(client *c) {
|
||||
|
@ -507,7 +507,9 @@ start_server {
|
||||
create_list xlist "$large c"
|
||||
assert_equal 3 [r rpushx xlist d]
|
||||
assert_equal 4 [r lpushx xlist a]
|
||||
assert_equal "a $large c d" [r lrange xlist 0 -1]
|
||||
assert_equal 6 [r rpushx xlist 42 x]
|
||||
assert_equal 9 [r lpushx xlist y3 y2 y1]
|
||||
assert_equal "y1 y2 y3 a $large c d 42 x" [r lrange xlist 0 -1]
|
||||
}
|
||||
|
||||
test "LINSERT - $type" {
|
||||
|
Loading…
x
Reference in New Issue
Block a user