【问题标题】:Filter based on Integer Comparison in Spring data redisSpring数据redis中基于整数比较的过滤器
【发布时间】: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);
}

我不喜欢从表中加载完整数据并使用任何循环/流进行搜索。

【问题讨论】:

标签: spring redis spring-data-redis


【解决方案1】:

我认为不会。我尝试使用

来实现您尝试做的事情
@Index
long lastUpdatedOn;

当我检查 redis 时,它给出了一个键 entity:lastUpdatedOn:160....,我尝试使用 ZRANGE 搜索它,但没有给出任何结果。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-06-22
    • 1970-01-01
    • 2019-11-27
    • 2018-04-23
    • 1970-01-01
    • 1970-01-01
    • 2021-05-13
    • 2013-09-22
    相关资源
    最近更新 更多