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

Function RM_StreamTrimByID

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

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

Source from the content-addressed store, hash-verified

3729 * - EBADF if the key is not opened for writing
3730 */
3731long 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

Callers

nothing calls this directly

Calls 1

streamTrimByIDFunction · 0.85

Tested by

no test coverage detected