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
dfab3cba
Commit
dfab3cba
authored
Oct 16, 2018
by
antirez
Browse files
Streams: XSTREAM SETID -> XSETID.
Keep vanilla stream commands at toplevel, see #5426.
parent
a3fb28ed
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/server.c
View file @
dfab3cba
...
...
@@ -314,7 +314,7 @@ struct redisCommand redisCommandTable[] = {
{
"xread"
,
xreadCommand
,
-
4
,
"rs"
,
0
,
xreadGetKeys
,
1
,
1
,
1
,
0
,
0
},
{
"xreadgroup"
,
xreadCommand
,
-
7
,
"ws"
,
0
,
xreadGetKeys
,
1
,
1
,
1
,
0
,
0
},
{
"xgroup"
,
xgroupCommand
,
-
2
,
"wm"
,
0
,
NULL
,
2
,
2
,
1
,
0
,
0
},
{
"xs
tream"
,
xstream
Command
,
-
2
,
"wmF
R
"
,
0
,
NULL
,
2
,
2
,
1
,
0
,
0
},
{
"xs
etid"
,
xsetid
Command
,
3
,
"wmF"
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"xack"
,
xackCommand
,
-
4
,
"wF"
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"xpending"
,
xpendingCommand
,
-
3
,
"r"
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"xclaim"
,
xclaimCommand
,
-
6
,
"wF"
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
...
...
src/server.h
View file @
dfab3cba
...
...
@@ -2111,7 +2111,7 @@ void xrevrangeCommand(client *c);
void
xlenCommand
(
client
*
c
);
void
xreadCommand
(
client
*
c
);
void
xgroupCommand
(
client
*
c
);
void
xs
tream
Command
(
client
*
c
);
void
xs
etid
Command
(
client
*
c
);
void
xackCommand
(
client
*
c
);
void
xpendingCommand
(
client
*
c
);
void
xclaimCommand
(
client
*
c
);
...
...
src/t_stream.c
View file @
dfab3cba
...
...
@@ -1775,73 +1775,23 @@ NULL
}
}
/* XSTREAM CREATE <key> <id or *>
* XSTREAM SETID <key> <id or $> */
void
xstreamCommand
(
client
*
c
)
{
const
char
*
help
[]
=
{
"CREATE <key> <id or *> -- Create a new empty stream."
,
"SETID <key> <id or $> -- Set the current stream ID."
,
"HELP -- Prints this help."
,
NULL
};
stream
*
s
=
NULL
;
char
*
opt
=
c
->
argv
[
1
]
->
ptr
;
/* Subcommand name. */
/* Dispatch the different subcommands. */
if
(
!
strcasecmp
(
opt
,
"CREATE"
)
&&
c
->
argc
==
4
)
{
robj
*
o
=
lookupKeyWrite
(
c
->
db
,
c
->
argv
[
2
]);
if
(
o
)
{
addReplySds
(
c
,
sdsnew
(
"-BUSYSTREAM Stream already exists
\r\n
"
));
return
;
}
else
{
streamID
id
;
if
(
!
strcmp
(
c
->
argv
[
3
]
->
ptr
,
"*"
))
{
id
.
ms
=
mstime
();
id
.
seq
=
0
;
}
else
if
(
streamParseStrictIDOrReply
(
c
,
c
->
argv
[
3
],
&
id
,
0
)
!=
C_OK
)
{
return
;
}
o
=
createStreamObject
();
s
=
o
->
ptr
;
s
->
last_id
=
id
;
dbAdd
(
c
->
db
,
c
->
argv
[
2
],
o
);
robj
*
idarg
=
createObjectFromStreamID
(
&
id
);
rewriteClientCommandArgument
(
c
,
3
,
idarg
);
decrRefCount
(
idarg
);
/* Set the internal "last ID" of a stream. */
void
xsetidCommand
(
client
*
c
)
{
robj
*
o
=
lookupKeyWriteOrReply
(
c
,
c
->
argv
[
1
],
shared
.
nokeyerr
);
if
(
o
==
NULL
||
checkType
(
c
,
o
,
OBJ_STREAM
))
return
;
addReply
(
c
,
shared
.
ok
);
server
.
dirty
++
;
notifyKeyspaceEvent
(
NOTIFY_STREAM
,
"xstream-create"
,
c
->
argv
[
2
],
c
->
db
->
id
);
}
}
else
if
(
!
strcasecmp
(
opt
,
"SETID"
)
&&
c
->
argc
==
4
)
{
robj
*
o
=
lookupKeyWriteOrReply
(
c
,
c
->
argv
[
2
],
shared
.
nokeyerr
);
if
(
o
==
NULL
||
checkType
(
c
,
o
,
OBJ_STREAM
))
return
;
s
=
o
->
ptr
;
streamID
id
;
if
(
!
strcmp
(
c
->
argv
[
3
]
->
ptr
,
"$"
))
{
id
=
s
->
last_id
;
}
else
if
(
streamParseStrictIDOrReply
(
c
,
c
->
argv
[
3
],
&
id
,
0
)
!=
C_OK
)
{
return
;
}
if
(
streamCompareID
(
&
id
,
&
s
->
last_id
)
<
0
)
{
addReplyError
(
c
,
"The ID specified in XSTREAM SETID is smaller than the "
"target stream top item"
);
return
;
}
s
->
last_id
=
id
;
addReply
(
c
,
shared
.
ok
);
server
.
dirty
++
;
notifyKeyspaceEvent
(
NOTIFY_STREAM
,
"xstream-setid"
,
c
->
argv
[
2
],
c
->
db
->
id
);
}
else
if
(
!
strcasecmp
(
opt
,
"HELP"
))
{
addReplyHelp
(
c
,
help
);
}
else
{
addReplySubcommandSyntaxError
(
c
);
stream
*
s
=
o
->
ptr
;
streamID
id
;
if
(
streamParseStrictIDOrReply
(
c
,
c
->
argv
[
3
],
&
id
,
0
)
!=
C_OK
)
return
;
if
(
streamCompareID
(
&
id
,
&
s
->
last_id
)
<
0
)
{
addReplyError
(
c
,
"The ID specified in XSETID is smaller than the "
"target stream top item"
);
return
;
}
s
->
last_id
=
id
;
addReply
(
c
,
shared
.
ok
);
server
.
dirty
++
;
notifyKeyspaceEvent
(
NOTIFY_STREAM
,
"xsetid"
,
c
->
argv
[
1
],
c
->
db
->
id
);
}
/* XACK <key> <group> <id> <id> ... <id>
...
...
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