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

Function RM_StreamIteratorDelete

src/module.cpp:3751–3772  ·  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

3749 * - ENOENT if the iterator has no current stream entry
3750 */
3751int RM_StreamIteratorDelete(RedisModuleKey *key) {
3752 if (!key) {
3753 errno = EINVAL;
3754 return REDISMODULE_ERR;
3755 } else if (!key->value || key->value->type != OBJ_STREAM) {
3756 errno = ENOTSUP;
3757 return REDISMODULE_ERR;
3758 } else if (!(key->mode & REDISMODULE_WRITE) || !key->iter) {
3759 errno = EBADF;
3760 return REDISMODULE_ERR;
3761 } else if (key->u.stream.currentid.ms == 0 &&
3762 key->u.stream.currentid.seq == 0) {
3763 errno = ENOENT;
3764 return REDISMODULE_ERR;
3765 }
3766 streamIterator *si = (streamIterator*)key->iter;
3767 streamIteratorRemoveEntry(si, &key->u.stream.currentid);
3768 key->u.stream.currentid.ms = 0; /* Make sure repeated Delete() fails */
3769 key->u.stream.currentid.seq = 0;
3770 key->u.stream.numfieldsleft = 0; /* Make sure NextField() fails */
3771 return REDISMODULE_OK;
3772}
3773
3774/* Trim a stream by length, similar to XTRIM with MAXLEN.
3775 *

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected