MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / streamRewriteTrimArgument

Function streamRewriteTrimArgument

src/t_stream.cpp:1772–1784  ·  view source on GitHub ↗

We propagate MAXLEN/MINID ~ as MAXLEN/MINID = * otherwise trimming is no longer deterministic on replicas / AOF. */

Source from the content-addressed store, hash-verified

1770/* We propagate MAXLEN/MINID ~ <count> as MAXLEN/MINID = <resulting-len-of-stream>
1771 * otherwise trimming is no longer deterministic on replicas / AOF. */
1772void streamRewriteTrimArgument(client *c, stream *s, int trim_strategy, int idx) {
1773 robj *arg;
1774 if (trim_strategy == TRIM_STRATEGY_MAXLEN) {
1775 arg = createStringObjectFromLongLong(s->length);
1776 } else {
1777 streamID first_id;
1778 streamGetEdgeID(s, 1, &first_id);
1779 arg = createObjectFromStreamID(&first_id);
1780 }
1781
1782 rewriteClientCommandArgument(c,idx,arg);
1783 decrRefCount(arg);
1784}
1785
1786/* XADD key [(MAXLEN [~|=] <count> | MINID [~|=] <id>) [LIMIT <entries>]] [NOMKSTREAM] <ID or *> [field value] [field value] ... */
1787void xaddCommand(client *c) {

Callers 2

xaddCommandFunction · 0.85
xtrimCommandFunction · 0.85

Calls 5

streamGetEdgeIDFunction · 0.85
createObjectFromStreamIDFunction · 0.85
decrRefCountFunction · 0.85

Tested by

no test coverage detected