Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for redis streams XTRIM eviction by ID, aka MINID #2250

Open
lrozek opened this issue Jan 27, 2022 · 2 comments
Open

Add support for redis streams XTRIM eviction by ID, aka MINID #2250

lrozek opened this issue Jan 27, 2022 · 2 comments
Labels
type: enhancement A general enhancement

Comments

@lrozek
Copy link

lrozek commented Jan 27, 2022

At the moment there is only support for eviction to the maximum length of a stream, aka MAXLEN
Please also consider adding support for MINID as in https://redis.io/commands/xtrim

spring classes that support XTRIM with MAXLEN but not MINID
StreamOperations#trim https://github.com/spring-projects/spring-data-redis/blob/3.0.x/src/main/java/org/springframework/data/redis/core/StreamOperations.java#L539 and https://github.com/spring-projects/spring-data-redis/blob/3.0.x/src/main/java/org/springframework/data/redis/core/StreamOperations.java#L552
RedisStreamCommands#xTrim https://github.com/spring-projects/spring-data-redis/blob/3.0.x/src/main/java/org/springframework/data/redis/connection/RedisStreamCommands.java#L909 and https://github.com/spring-projects/spring-data-redis/blob/3.0.x/src/main/java/org/springframework/data/redis/connection/RedisStreamCommands.java#L922

lettuce already offers API to trim by MINID
RedisStreamAsyncCommands#xtrim with XTrimArgs argument, XTrimArgs has minId field for that https://github.com/lettuce-io/lettuce-core/blob/main/src/main/java/io/lettuce/core/api/async/RedisStreamAsyncCommands.java#L366

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 27, 2022
@odrotbohm odrotbohm added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Feb 7, 2022
@ddovbis
Copy link

ddovbis commented Jun 28, 2023

Any ETA on this, or a workaround (e.g., sending custom commands to redis via redis template)?

@bringyou
Copy link

A workaround, use RedisCommands.execute to send custom command.
Full snippet in kotlin

redisTemplate.execute {
        val args = arrayOf("streamkey", "MINID", "~", "messageId").map { it.toByteArray() }.toTypedArray()
        it.execute("XTRIM", *args)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

5 participants