Skip to content

Use Redis multiple get operation #3150

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

Open
ceremo opened this issue May 14, 2025 · 1 comment
Open

Use Redis multiple get operation #3150

ceremo opened this issue May 14, 2025 · 1 comment
Assignees
Labels
type: enhancement A general enhancement

Comments

@ceremo
Copy link

ceremo commented May 14, 2025

Redis repositories are based on KeyValueRepository, this interface defines Iterable<T> findAllById(Iterable<ID> ids), and the implementation defines a loop executing a findById per id (SimpleKeyValueRepository), but Redis could instead use the operation MGET to execute in a single request to the Redis server all requested ids.

Have you analyzed this alternative? Or maybe adding an extra method like Iterable<T> multiFindById(Iterable<ID> ids) taking advantage of the operation MGET?

Thanks for your time.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 14, 2025
@dfidalgo-jpm
Copy link

Hello, I'm interested in this. I am using spring-data-redis repositories and findAllById is very slow. As I cannot use MGET for that, I switched to something like:

redisTemplate.executePipelined { connection: RedisConnection ->
                val serializer = redisTemplate.stringSerializer

                for (key in keys) {
                    serializer.serialize(key)?.let { connection.hashCommands().hGetAll(it) }
                }
                null
            } 

But it would be nice if it was backed in the provided repositories.

@mp911de mp911de added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels May 19, 2025
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