【发布时间】:2020-07-23 08:38:47
【问题描述】:
我正在使用 spring-data-redis 与数据库通信。
我有如下实体类
@RedisHash(value = "employee")
public class Employee
{
@Id
private long id;
@Indexed
private String name;
@Indexed
private int age;
private Address address;
...... ...... ......
}
我想根据年龄组过滤员工。例如,年龄小于 35 岁(age
@Repository
public interface EmployeeRepo extends CrudRepository<Employee, Long>
{
public Employee findByName(String name);
}
我不喜欢从表中加载完整数据并使用任何循环/流进行搜索。
【问题讨论】:
-
Redis 是一个键值对存储,它只能为您提供基于键的搜索。
标签: spring redis spring-data-redis