spring-data-redis icon indicating copy to clipboard operation
spring-data-redis copied to clipboard

`ReactiveKeyCommands.Exists` to check multiple key existence

Open kutlueren opened this issue 10 months ago • 7 comments

I am using the function to check if a key exist or not, but actually I have a list of keys that needs to be checked. I can't find a func that would accept a list of keys and do this as a bulk check. Is there a reason why this was not implemented? if not, would that be possible to implement it? it is already implemented in jedis.

I have achieved this by the following implementation:

 redisOperations.execute { connection ->
                val keyCommands = connection.keyCommands()
                val existsMonos = keys.map { key ->
                    keyCommands.exists(ByteBuffer.wrap(key))
                        .map { it == true }
                        .onErrorReturn(false)
                }
                Mono.zip(existsMonos) { it }
            }.awaitFirst()

redisOperations is a ReactiveRedisOperations type.

The versions:

org.springframework.data:spring-data-redis:3.2.2 java 21.0.2-librca Kotlin compiler version 1.9.22

Thank you

kutlueren avatar Mar 28 '24 09:03 kutlueren

Currently, exists supports only single-key arguments. It makes sense to introduce method overloads returning a result for multiple keys.

mp911de avatar Apr 04 '24 13:04 mp911de

May I handle this issue? I will figure it out and open PR if possible.

AnneMayor avatar May 11 '24 14:05 AnneMayor

Sure, feel free to have a look @AnneMayor

mp911de avatar May 13 '24 09:05 mp911de

Thank, @mp911de I will go on after #2905 PR merged :)

AnneMayor avatar May 13 '24 14:05 AnneMayor

Awesome to see that it is being tackled 👏🏻

kutlueren avatar May 21 '24 09:05 kutlueren

@kutlueren Hi🙂Thanks for asking. I am handling this issue for now. I am going to open PR within this weekend. If there's no PR after that you can take this one instead🙂

AnneMayor avatar May 21 '24 09:05 AnneMayor

@AnneMayor thanks a lot! I initially wanted to tackle it but it was beyond my comprehension. I am happy to review your PR though 🙂

kutlueren avatar May 21 '24 09:05 kutlueren