我有一个在spring数据中建模的哈希表,如下所示:
@RedisHash("Entity")
@Data
@AllArgsConstructor
public class Entity implements Serializable {
private String id;
private String status;
private String name;
}
我有这样一个完整的描述:
@Repository
public interface EntityRepository extends CrudRepository<Entity, String> {}
我有这样一个实体服务:
@Service
public class EntityService {
@Autowired
private EntityRepository entityRepository;
public List<Entity> getAllByName(String name) {
// Code that gets all Entities stored in my redis table that have a certain name
}
public List<Entity> getAllByStatus(String status) {
// Code that gets all Entities stored in my redis table that have a certain status
}
如何在redis中搜索具有特定名称/状态的所有实体?
1条答案
按热度按时间ia2d9nvy1#
我遵循了这里的文档,并能够解决我的问题。我将querybyexampleexecutor接口添加到我的存储库中,如下所示:
使用示例类,我实现了如下getallbyname: