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
aba76320
Commit
aba76320
authored
Apr 18, 2018
by
antirez
Browse files
Streams: XDEL command.
parent
9c149bf1
Changes
3
Show whitespace changes
Inline
Side-by-side
src/server.c
View file @
aba76320
...
...
@@ -313,6 +313,7 @@ struct redisCommand redisCommandTable[] = {
{
"xpending"
,
xpendingCommand
,
-
3
,
"r"
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"xclaim"
,
xclaimCommand
,
-
5
,
"wF"
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"xinfo"
,
xinfoCommand
,
-
2
,
"r"
,
0
,
NULL
,
2
,
2
,
1
,
0
,
0
},
{
"xdel"
,
xdelCommand
,
-
2
,
"wF"
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"post"
,
securityWarningCommand
,
-
1
,
"lt"
,
0
,
NULL
,
0
,
0
,
0
,
0
,
0
},
{
"host:"
,
securityWarningCommand
,
-
1
,
"lt"
,
0
,
NULL
,
0
,
0
,
0
,
0
,
0
},
{
"latency"
,
latencyCommand
,
-
2
,
"aslt"
,
0
,
NULL
,
0
,
0
,
0
,
0
,
0
}
...
...
src/server.h
View file @
aba76320
...
...
@@ -2053,6 +2053,7 @@ void xackCommand(client *c);
void
xpendingCommand
(
client
*
c
);
void
xclaimCommand
(
client
*
c
);
void
xinfoCommand
(
client
*
c
);
void
xdelCommand
(
client
*
c
);
#if defined(__GNUC__)
void
*
calloc
(
size_t
count
,
size_t
size
)
__attribute__
((
deprecated
));
...
...
src/t_stream.c
View file @
aba76320
...
...
@@ -715,10 +715,10 @@ void streamIteratorStop(streamIterator *si) {
/* Delete the specified item ID from the stream, returning 1 if the item
* was deleted 0 otherwise (if it does not exist). */
int
streamDeleteItem
(
stream
*
s
,
streamID
id
)
{
int
streamDeleteItem
(
stream
*
s
,
streamID
*
id
)
{
int
deleted
=
0
;
streamIterator
si
;
streamIteratorStart
(
&
si
,
s
,
&
id
,
&
id
,
0
);
streamIteratorStart
(
&
si
,
s
,
id
,
id
,
0
);
streamID
myid
;
int64_t
numfields
;
if
(
streamIteratorGetID
(
&
si
,
&
myid
,
&
numfields
))
{
...
...
@@ -1992,6 +1992,35 @@ void xclaimCommand(client *c) {
preventCommandPropagation
(
c
);
}
/* XDEL <key> [<ID1> <ID2> ... <IDN>]
*
* Removes the specified entries from the stream. Returns the number
* of items actaully deleted, that may be different from the number
* of IDs passed in case certain IDs do not exist. */
void
xdelCommand
(
client
*
c
)
{
robj
*
o
;
if
((
o
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
))
==
NULL
||
checkType
(
c
,
o
,
OBJ_STREAM
))
return
;
stream
*
s
=
o
->
ptr
;
/* We need to sanity check the IDs passed to start. Even if not
* a big issue, it is not great that the command is only partially
* executed becuase at some point an invalid ID is parsed. */
streamID
id
;
for
(
int
j
=
2
;
j
<
c
->
argc
;
j
++
)
{
if
(
streamParseIDOrReply
(
c
,
c
->
argv
[
j
],
&
id
,
0
)
!=
C_OK
)
return
;
}
/* Actaully apply the command. */
int
deleted
=
0
;
for
(
int
j
=
2
;
j
<
c
->
argc
;
j
++
)
{
streamParseIDOrReply
(
c
,
c
->
argv
[
j
],
&
id
,
0
);
/* Retval already checked. */
deleted
+=
streamDeleteItem
(
s
,
&
id
);
}
addReplyLongLong
(
c
,
deleted
);
}
/* XINFO CONSUMERS key group
* XINFO GROUPS <key>
* XINFO STREAM <key>
...
...
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