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
b3a96d45
Commit
b3a96d45
authored
Apr 19, 2011
by
antirez
Browse files
Variadic SREM
parent
64a13a36
Changes
3
Show whitespace changes
Inline
Side-by-side
src/redis.c
View file @
b3a96d45
...
...
@@ -103,7 +103,7 @@ struct redisCommand redisCommandTable[] = {
{"lrem",lremCommand,4,0,NULL,1,1,1,0,0},
{"rpoplpush",rpoplpushCommand,3,REDIS_CMD_DENYOOM,NULL,1,2,1,0,0},
{"sadd",saddCommand,-3,REDIS_CMD_DENYOOM,NULL,1,1,1,0,0},
{"srem",sremCommand,3,0,NULL,1,1,1,0,0},
{"srem",sremCommand,
-
3,0,NULL,1,1,1,0,0},
{"smove",smoveCommand,4,0,NULL,1,2,1,0,0},
{"sismember",sismemberCommand,3,0,NULL,1,1,1,0,0},
{"scard",scardCommand,2,0,NULL,1,1,1,0,0},
...
...
src/t_set.c
View file @
b3a96d45
...
...
@@ -242,19 +242,22 @@ void saddCommand(redisClient *c) {
void
sremCommand
(
redisClient
*
c
)
{
robj
*
set
;
int
j
,
deleted
=
0
;
if
((
set
=
lookupKeyWriteOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
))
==
NULL
||
checkType
(
c
,
set
,
REDIS_SET
))
return
;
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
if
(
setTypeRemove
(
set
,
c
->
argv
[
2
]))
{
for
(
j
=
2
;
j
<
c
->
argc
;
j
++
)
{
if
(
setTypeRemove
(
set
,
c
->
argv
[
j
]))
{
if
(
setTypeSize
(
set
)
==
0
)
dbDelete
(
c
->
db
,
c
->
argv
[
1
]);
deleted
++
;
}
}
if
(
deleted
)
{
signalModifiedKey
(
c
->
db
,
c
->
argv
[
1
]);
server
.
dirty
++
;
addReply
(
c
,
shared
.
cone
);
}
else
{
addReply
(
c
,
shared
.
czero
);
server
.
dirty
+=
deleted
;
}
addReplyLongLong
(
c
,
deleted
);
}
void
smoveCommand
(
redisClient
*
c
)
{
...
...
tests/unit/type/set.tcl
View file @
b3a96d45
...
...
@@ -97,6 +97,14 @@ start_server {
assert_equal
{
3 5
}
[
lsort
[
r smembers myset
]]
}
test
{
SREM with multiple arguments
}
{
r del myset
r sadd myset a b c d
assert_equal 0
[
r srem myset k k k
]
assert_equal 2
[
r srem myset b d x y
]
lsort
[
r smembers myset
]
}
{
a c
}
foreach
{
type
}
{
hashtable intset
}
{
for
{
set i 1
}
{
$i
<= 5
}
{
incr i
}
{
r del
[
format
"set%d"
$i
]
...
...
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