Trim a stream by ID, similar to XTRIM with MINID. * * - `key`: Key opened for writing. * - `flags`: A bitfield of * - `REDISMODULE_STREAM_TRIM_APPROX`: Trim less if it improves performance, * like XTRIM with `~`. * - `id`: The smallest stream ID to keep after trimming. * * Returns the number of entries deleted. On failure, a negative value is * returned and `errno` is set as follows
| 3729 | * - EBADF if the key is not opened for writing |
| 3730 | */ |
| 3731 | long long RM_StreamTrimByID(RedisModuleKey *key, int flags, RedisModuleStreamID *id) { |
| 3732 | if (!key || (flags & ~(REDISMODULE_STREAM_TRIM_APPROX)) || !id) { |
| 3733 | errno = EINVAL; |
| 3734 | return -1; |
| 3735 | } else if (!key->value || key->value->type != OBJ_STREAM) { |
| 3736 | errno = ENOTSUP; |
| 3737 | return -1; |
| 3738 | } else if (!(key->mode & REDISMODULE_WRITE)) { |
| 3739 | errno = EBADF; |
| 3740 | return -1; |
| 3741 | } |
| 3742 | int approx = flags & REDISMODULE_STREAM_TRIM_APPROX ? 1 : 0; |
| 3743 | streamID minid = (streamID){id->ms, id->seq}; |
| 3744 | return streamTrimByID((stream *)key->value->ptr, minid, approx); |
| 3745 | } |
| 3746 | |
| 3747 | /* -------------------------------------------------------------------------- |
| 3748 | * ## Calling Redis commands from modules |
nothing calls this directly
no test coverage detected