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

Function streamNextID

src/t_stream.cpp:135–144  ·  view source on GitHub ↗

Generate the next stream item ID given the previous one. If the current * milliseconds Unix time is greater than the previous one, just use this * as time part and start with sequence part of zero. Otherwise we use the * previous time (and never go backward) and increment the sequence. */

Source from the content-addressed store, hash-verified

133 * as time part and start with sequence part of zero. Otherwise we use the
134 * previous time (and never go backward) and increment the sequence. */
135void streamNextID(streamID *last_id, streamID *new_id) {
136 uint64_t ms = mstime();
137 if (ms > last_id->ms) {
138 new_id->ms = ms;
139 new_id->seq = 0;
140 } else {
141 *new_id = *last_id;
142 streamIncrID(new_id);
143 }
144}
145
146/* This is a helper function for the COPY command.
147 * Duplicate a Stream object, with the guarantee that the returned object

Callers 1

streamAppendItemFunction · 0.85

Calls 2

streamIncrIDFunction · 0.85
mstimeFunction · 0.70

Tested by

no test coverage detected