Reputation: 137
is there a way we can implement Range queries in Redis using Spring Data Redis?
Eg:
If my Pojo class has Date(which is not a primary key) and i require data that falls under a desired period of date, Is it possible with Spring Data Redis to construct a query for the same rather than querying each date individually?
Upvotes: 3
Views: 1384
Reputation: 1705
For Redis ZSets you have ZSetOperations
interface that have several range commands (see see https://docs.spring.io/spring-data/redis/docs/2.5.1/api/org/springframework/data/redis/connection/RedisZSetCommands.html), the main one being:
range(K key, long start, long end)
Plus, several rangeByXXX
ones.
More info on Redis ZSets and range operations see https://redis.io/commands/zrange
If you want more powerful queries I recommend you take a look at RediSearch (https://oss.redislabs.com/redisearch/). There is Spring Integration here https://oss.redislabs.com/redisearch/
Upvotes: 1