Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
d88c3c77
Commit
d88c3c77
authored
Jun 05, 2016
by
Pierre Chapuis
Browse files
make RPUSHX and LPUSHX variadic
parent
b670a162
Changes
3
Show whitespace changes
Inline
Side-by-side
src/server.c
View file @
d88c3c77
...
...
@@ -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},
...
...
src/t_list.c
View file @
d88c3c77
...
...
@@ -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
;
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"
;
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
++
;
addReplyLongLong
(
c
,
listTypeLength
(
subject
));
}
server
.
dirty
+=
pushed
;
}
void
lpushxCommand
(
client
*
c
)
{
...
...
tests/unit/type/list.tcl
View file @
d88c3c77
...
...
@@ -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
"
{
...
...
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