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

Function RM_StreamDelete

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

Deletes an entry from a stream. * * - `key`: A key opened for writing, with no stream iterator started. * - `id`: The stream ID of the entry to delete. * * Returns REDISMODULE_OK on success. On failure, REDISMODULE_ERR is returned * and `errno` is set as follows: * * - EINVAL if called with invalid arguments * - ENOTSUP if the key refers to a value of a type other than stream or if the *

Source from the content-addressed store, hash-verified

3399 * iterating using a stream iterator.
3400 */
3401int RM_StreamDelete(RedisModuleKey *key, RedisModuleStreamID *id) {
3402 if (!key || !id) {
3403 errno = EINVAL;
3404 return REDISMODULE_ERR;
3405 } else if (!key->value || key->value->type != OBJ_STREAM) {
3406 errno = ENOTSUP; /* wrong type */
3407 return REDISMODULE_ERR;
3408 } else if (!(key->mode & REDISMODULE_WRITE) ||
3409 key->iter != NULL) {
3410 errno = EBADF; /* key not opened for writing or iterator started */
3411 return REDISMODULE_ERR;
3412 }
3413 stream *s = key->value->ptr;
3414 streamID streamid = {id->ms, id->seq};
3415 if (streamDeleteItem(s, &streamid)) {
3416 return REDISMODULE_OK;
3417 } else {
3418 errno = ENOENT; /* no entry with this id */
3419 return REDISMODULE_ERR;
3420 }
3421}
3422
3423/* Sets up a stream iterator.
3424 *

Callers

nothing calls this directly

Calls 1

streamDeleteItemFunction · 0.85

Tested by

no test coverage detected