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 *
| 3487 | * iterating using a stream iterator. |
| 3488 | */ |
| 3489 | int 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 | * |
nothing calls this directly
no test coverage detected