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

Function RM_StreamIteratorDelete

app/redis-6.2.6/src/module.c:3663–3684  ·  view source on GitHub ↗

Deletes the current stream entry while iterating. * * This function can be called after RM_StreamIteratorNextID() or after any * calls to RM_StreamIteratorNextField(). * * Returns REDISMODULE_OK on success. On failure, REDISMODULE_ERR is returned * and `errno` is set as follows: * * - EINVAL if key is NULL * - ENOTSUP if the key is empty or is of another type than stream * - EBADF if the

Source from the content-addressed store, hash-verified

3661 * - ENOENT if the iterator has no current stream entry
3662 */
3663int RM_StreamIteratorDelete(RedisModuleKey *key) {
3664 if (!key) {
3665 errno = EINVAL;
3666 return REDISMODULE_ERR;
3667 } else if (!key->value || key->value->type != OBJ_STREAM) {
3668 errno = ENOTSUP;
3669 return REDISMODULE_ERR;
3670 } else if (!(key->mode & REDISMODULE_WRITE) || !key->iter) {
3671 errno = EBADF;
3672 return REDISMODULE_ERR;
3673 } else if (key->u.stream.currentid.ms == 0 &&
3674 key->u.stream.currentid.seq == 0) {
3675 errno = ENOENT;
3676 return REDISMODULE_ERR;
3677 }
3678 streamIterator *si = key->iter;
3679 streamIteratorRemoveEntry(si, &key->u.stream.currentid);
3680 key->u.stream.currentid.ms = 0; /* Make sure repeated Delete() fails */
3681 key->u.stream.currentid.seq = 0;
3682 key->u.stream.numfieldsleft = 0; /* Make sure NextField() fails */
3683 return REDISMODULE_OK;
3684}
3685
3686/* Trim a stream by length, similar to XTRIM with MAXLEN.
3687 *

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected