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
d22f1ef0
Commit
d22f1ef0
authored
Oct 08, 2018
by
zhaozhao.zz
Committed by
antirez
Oct 17, 2018
Browse files
Stream & AOF: rewrite stream in correct way
parent
6455274d
Changes
1
Show whitespace changes
Inline
Side-by-side
src/aof.c
View file @
d22f1ef0
...
...
@@ -1139,6 +1139,7 @@ int rewriteStreamObject(rio *r, robj *key, robj *o) {
streamID
id
;
int64_t
numfields
;
if
(
s
->
length
)
{
/* Reconstruct the stream data using XADD commands. */
while
(
streamIteratorGetID
(
&
si
,
&
id
,
&
numfields
))
{
/* Emit a two elements array for each item. The first is
...
...
@@ -1157,6 +1158,21 @@ int rewriteStreamObject(rio *r, robj *key, robj *o) {
if
(
rioWriteBulkString
(
r
,(
char
*
)
value
,
value_len
)
==
0
)
return
0
;
}
}
/* Append XSTREAM SETID after XADD, make sure lastid is correct,
* in case of XDEL lastid. */
if
(
rioWriteBulkCount
(
r
,
'*'
,
4
)
==
0
)
return
0
;
if
(
rioWriteBulkString
(
r
,
"XSTREAM"
,
7
)
==
0
)
return
0
;
if
(
rioWriteBulkString
(
r
,
"SETID"
,
5
)
==
0
)
return
0
;
if
(
rioWriteBulkObject
(
r
,
key
)
==
0
)
return
0
;
if
(
rioWriteBulkStreamID
(
r
,
&
s
->
last_id
)
==
0
)
return
0
;
}
else
{
/* Using XSTREAM CREATE if the stream is empty. */
if
(
rioWriteBulkCount
(
r
,
'*'
,
4
)
==
0
)
return
0
;
if
(
rioWriteBulkString
(
r
,
"XSTREAM"
,
7
)
==
0
)
return
0
;
if
(
rioWriteBulkString
(
r
,
"CREATE"
,
6
)
==
0
)
return
0
;
if
(
rioWriteBulkObject
(
r
,
key
)
==
0
)
return
0
;
if
(
rioWriteBulkStreamID
(
r
,
&
s
->
last_id
)
==
0
)
return
0
;
}
/* Create all the stream consumer groups. */
if
(
s
->
cgroups
)
{
...
...
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