Home > database >  Spring data redis implementation redis zrevrangebyscore operation
Spring data redis implementation redis zrevrangebyscore operation

Time:10-06

I have a question because there is something that does not work well in the operation of spring data redis.

There was no problem with the inquiry when I used redis-cli, but when I use the API of spring data redis

it failed to retrieve results, so I am asking if there is another way or if I made a mistake.

when redis-cli

$zrevrangebyscore redis_key  inf (1664142666 withscores

1) "189:Z0000539"
2) "1664432446"
3) "192:Z0000288"
4) "1664332797"
5) "178:0000cq4e"
6) "1664256182"

In Spring data redis

private val stringRedisTemplate: StringRedisTemplate
val now = Instant.now().epochSecond - (86400 * 7L);


val res = stringRedisTemplate.opsForZSet().reverseRangeByScore(
            "redis_key",
            0.0,
            now.toDouble()
        )
res //<- empty

I'd appreciate it if you could give me your opinion.

CodePudding user response:

You are replacing inf in redis-cli with 0.0 in spring-data-redis which does not seem a logical replacement.

Try Double.POSITIVE_INFINITY instead of 0.0.

  • Related