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

Function RM_StreamDelete

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

3487 * iterating using a stream iterator.
3488 */
3489int RM_StreamDelete(RedisModuleKey *key, RedisModuleStreamID *id) {
3490 if (!key || !id) {
3491 errno = EINVAL;
3492 return REDISMODULE_ERR;
3493 } else if (!key->value || key->value->type != OBJ_STREAM) {
3494 errno = ENOTSUP; /* wrong type */
3495 return REDISMODULE_ERR;
3496 } else if (!(key->mode & REDISMODULE_WRITE) ||
3497 key->iter != NULL) {
3498 errno = EBADF; /* key not opened for writing or iterator started */
3499 return REDISMODULE_ERR;
3500 }
3501 stream *s = (stream*)ptrFromObj(key->value);
3502 streamID streamid = {id->ms, id->seq};
3503 if (streamDeleteItem(s, &streamid)) {
3504 return REDISMODULE_OK;
3505 } else {
3506 errno = ENOENT; /* no entry with this id */
3507 return REDISMODULE_ERR;
3508 }
3509}
3510
3511/* Sets up a stream iterator.
3512 *

Callers

nothing calls this directly

Calls 2

ptrFromObjFunction · 0.85
streamDeleteItemFunction · 0.85

Tested by

no test coverage detected