mirror of
https://github.com/fluencelabs/redis
synced 2025-04-01 23:31:03 +00:00
Stream & AOF: rewrite stream in correct way
This commit is contained in:
parent
5f3adbee33
commit
b3e80d2f65
16
src/aof.c
16
src/aof.c
@ -1121,6 +1121,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
|
||||
@ -1139,6 +1140,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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user