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
9bb18e54
Commit
9bb18e54
authored
Nov 20, 2017
by
antirez
Browse files
Streams: XRANGE REV option -> XREVRANGE command.
parent
9dc79c03
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/server.c
View file @
9bb18e54
...
@@ -304,6 +304,7 @@ struct redisCommand redisCommandTable[] = {
...
@@ -304,6 +304,7 @@ struct redisCommand redisCommandTable[] = {
{
"pfdebug"
,
pfdebugCommand
,
-
3
,
"w"
,
0
,
NULL
,
0
,
0
,
0
,
0
,
0
},
{
"pfdebug"
,
pfdebugCommand
,
-
3
,
"w"
,
0
,
NULL
,
0
,
0
,
0
,
0
,
0
},
{
"xadd"
,
xaddCommand
,
-
5
,
"wmF"
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"xadd"
,
xaddCommand
,
-
5
,
"wmF"
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"xrange"
,
xrangeCommand
,
-
4
,
"r"
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"xrange"
,
xrangeCommand
,
-
4
,
"r"
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"xrevrange"
,
xrevrangeCommand
,
-
4
,
"r"
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"xlen"
,
xlenCommand
,
2
,
"rF"
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"xlen"
,
xlenCommand
,
2
,
"rF"
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"xread"
,
xreadCommand
,
-
3
,
"rs"
,
0
,
xreadGetKeys
,
1
,
1
,
1
,
0
,
0
},
{
"xread"
,
xreadCommand
,
-
3
,
"rs"
,
0
,
xreadGetKeys
,
1
,
1
,
1
,
0
,
0
},
{
"post"
,
securityWarningCommand
,
-
1
,
"lt"
,
0
,
NULL
,
0
,
0
,
0
,
0
,
0
},
{
"post"
,
securityWarningCommand
,
-
1
,
"lt"
,
0
,
NULL
,
0
,
0
,
0
,
0
,
0
},
...
...
src/server.h
View file @
9bb18e54
...
@@ -2010,6 +2010,7 @@ void moduleCommand(client *c);
...
@@ -2010,6 +2010,7 @@ void moduleCommand(client *c);
void
securityWarningCommand
(
client
*
c
);
void
securityWarningCommand
(
client
*
c
);
void
xaddCommand
(
client
*
c
);
void
xaddCommand
(
client
*
c
);
void
xrangeCommand
(
client
*
c
);
void
xrangeCommand
(
client
*
c
);
void
xrevrangeCommand
(
client
*
c
);
void
xlenCommand
(
client
*
c
);
void
xlenCommand
(
client
*
c
);
void
xreadCommand
(
client
*
c
);
void
xreadCommand
(
client
*
c
);
...
...
src/t_stream.c
View file @
9bb18e54
...
@@ -856,16 +856,17 @@ void xaddCommand(client *c) {
...
@@ -856,16 +856,17 @@ void xaddCommand(client *c) {
signalKeyAsReady
(
c
->
db
,
c
->
argv
[
1
]);
signalKeyAsReady
(
c
->
db
,
c
->
argv
[
1
]);
}
}
/* XRANGE
key start end [COUNT <n>] [REV]
*/
/* XRANGE
/XREVRANGE actual implementation.
*/
void
xrangeCommand
(
client
*
c
)
{
void
xrange
Generic
Command
(
client
*
c
,
int
rev
)
{
robj
*
o
;
robj
*
o
;
stream
*
s
;
stream
*
s
;
streamID
startid
,
endid
;
streamID
startid
,
endid
;
long
long
count
=
0
;
long
long
count
=
0
;
int
rev
=
0
;
robj
*
startarg
=
rev
?
c
->
argv
[
3
]
:
c
->
argv
[
2
];
robj
*
endarg
=
rev
?
c
->
argv
[
2
]
:
c
->
argv
[
3
];
if
(
streamParseIDOrReply
(
c
,
c
->
argv
[
2
]
,
&
startid
,
0
)
==
C_ERR
)
return
;
if
(
streamParseIDOrReply
(
c
,
startarg
,
&
startid
,
0
)
==
C_ERR
)
return
;
if
(
streamParseIDOrReply
(
c
,
c
->
argv
[
3
]
,
&
endid
,
UINT64_MAX
)
==
C_ERR
)
return
;
if
(
streamParseIDOrReply
(
c
,
endarg
,
&
endid
,
UINT64_MAX
)
==
C_ERR
)
return
;
/* Parse the COUNT option if any. */
/* Parse the COUNT option if any. */
if
(
c
->
argc
>
4
)
{
if
(
c
->
argc
>
4
)
{
...
@@ -876,8 +877,6 @@ void xrangeCommand(client *c) {
...
@@ -876,8 +877,6 @@ void xrangeCommand(client *c) {
!=
C_OK
)
return
;
!=
C_OK
)
return
;
if
(
count
<
0
)
count
=
0
;
if
(
count
<
0
)
count
=
0
;
j
++
;
/* Consume additional arg. */
j
++
;
/* Consume additional arg. */
}
else
if
(
strcasecmp
(
c
->
argv
[
j
]
->
ptr
,
"REV"
)
==
0
)
{
rev
=
1
;
}
else
{
}
else
{
addReply
(
c
,
shared
.
syntaxerr
);
addReply
(
c
,
shared
.
syntaxerr
);
return
;
return
;
...
@@ -892,6 +891,16 @@ void xrangeCommand(client *c) {
...
@@ -892,6 +891,16 @@ void xrangeCommand(client *c) {
streamReplyWithRange
(
c
,
s
,
&
startid
,
&
endid
,
count
,
rev
);
streamReplyWithRange
(
c
,
s
,
&
startid
,
&
endid
,
count
,
rev
);
}
}
/* XRANGE key start end [COUNT <n>] */
void
xrangeCommand
(
client
*
c
)
{
xrangeGenericCommand
(
c
,
0
);
}
/* XREVRANGE key end start [COUNT <n>] */
void
xrevrangeCommand
(
client
*
c
)
{
xrangeGenericCommand
(
c
,
1
);
}
/* XLEN */
/* XLEN */
void
xlenCommand
(
client
*
c
)
{
void
xlenCommand
(
client
*
c
)
{
robj
*
o
;
robj
*
o
;
...
...
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