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