问题
I am using spring-data-redis to communicate with database.
I have entity class like below
@RedisHash(value = "employee")
public class Employee
{
@Id
private long id;
@Indexed
private String name;
@Indexed
private int age;
private Address address;
...... ...... ......
}
I want to filter the employees based on age group. For example, age lesser than 35 (age<35). How to achieve this in below repository?
@Repository
public interface EmployeeRepo extends CrudRepository<Employee, Long>
{
public Employee findByName(String name);
}
I dont prefer to load complete data from table and do search using any loop/stream.
回答1:
I don't think it does. I tried to implement what you tried to do using
@Index
long lastUpdatedOn;
when I checked the redis it gives a key entity:lastUpdatedOn:160....
and I tried searching for it using ZRANGE
which gives no results.
来源:https://stackoverflow.com/questions/63050222/filter-based-on-integer-comparison-in-spring-data-redis