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
29a87f23
Commit
29a87f23
authored
Apr 21, 2011
by
antirez
Browse files
Variadic SREM backported from unstable
parent
0882fe5e
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/redis.c
View file @
29a87f23
...
...
@@ -103,7 +103,7 @@ struct redisCommand readonlyCommandTable[] = {
{
"lrem"
,
lremCommand
,
4
,
0
,
NULL
,
1
,
1
,
1
},
{
"rpoplpush"
,
rpoplpushCommand
,
3
,
REDIS_CMD_DENYOOM
,
NULL
,
1
,
2
,
1
},
{
"sadd"
,
saddCommand
,
-
3
,
REDIS_CMD_DENYOOM
,
NULL
,
1
,
1
,
1
},
{
"srem"
,
sremCommand
,
3
,
0
,
NULL
,
1
,
1
,
1
},
{
"srem"
,
sremCommand
,
-
3
,
0
,
NULL
,
1
,
1
,
1
},
{
"smove"
,
smoveCommand
,
4
,
0
,
NULL
,
1
,
2
,
1
},
{
"sismember"
,
sismemberCommand
,
3
,
0
,
NULL
,
1
,
1
,
1
},
{
"scard"
,
scardCommand
,
2
,
0
,
NULL
,
1
,
1
,
1
},
...
...
src/t_set.c
View file @
29a87f23
...
...
@@ -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
]))
{
if
(
setTypeSize
(
set
)
==
0
)
dbDelete
(
c
->
db
,
c
->
argv
[
1
]);
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
)
{
touchWatchedKey
(
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 @
29a87f23
...
...
@@ -90,6 +90,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