MCPcopy Create free account
hub / github.com/F-Stack/f-stack / xsetidCommand

Function xsetidCommand

app/redis-6.2.6/src/t_stream.c:2507–2532  ·  view source on GitHub ↗

XSETID * * Set the internal "last ID" of a stream. */

Source from the content-addressed store, hash-verified

2505 *
2506 * Set the internal "last ID" of a stream. */
2507void xsetidCommand(client *c) {
2508 robj *o = lookupKeyWriteOrReply(c,c->argv[1],shared.nokeyerr);
2509 if (o == NULL || checkType(c,o,OBJ_STREAM)) return;
2510
2511 stream *s = o->ptr;
2512 streamID id;
2513 if (streamParseStrictIDOrReply(c,c->argv[2],&id,0) != C_OK) return;
2514
2515 /* If the stream has at least one item, we want to check that the user
2516 * is setting a last ID that is equal or greater than the current top
2517 * item, otherwise the fundamental ID monotonicity assumption is violated. */
2518 if (s->length > 0) {
2519 streamID maxid;
2520 streamLastValidID(s,&maxid);
2521
2522 if (streamCompareID(&id,&maxid) < 0) {
2523 addReplyError(c,"The ID specified in XSETID is smaller than the "
2524 "target stream top item");
2525 return;
2526 }
2527 }
2528 s->last_id = id;
2529 addReply(c,shared.ok);
2530 server.dirty++;
2531 notifyKeyspaceEvent(NOTIFY_STREAM,"xsetid",c->argv[1],c->db->id);
2532}
2533
2534/* XACK <key> <group> <id> <id> ... <id>
2535 *

Callers

nothing calls this directly

Calls 8

lookupKeyWriteOrReplyFunction · 0.85
checkTypeFunction · 0.85
streamLastValidIDFunction · 0.85
streamCompareIDFunction · 0.85
addReplyErrorFunction · 0.85
addReplyFunction · 0.85
notifyKeyspaceEventFunction · 0.85

Tested by

no test coverage detected