0
我只是试图将项目的结果存储在缓存中,并且除了密钥以外都一切顺利。春季数据中的咖啡因缓存密钥jpa
SimpleKeyGenerator通常会保存基于参数的对象或结果,在我的情况下,我想要将对象存储在缓存中,并且键应该是列表中对象的属性,这里是一个示例。
public class Item{
private Long id;
private Long reference;
private Integer status;
//setter and getter
}
public interface ItemRepository extends JpaRepository<Long,Item>{
@Cachable("items")
List<Item> findByReferenceAndStatus(Long reference, Integer status);
}
现在我要存储在基于item.id缓存每个对象,我知道我们可以使用注释的关键属性,但我怎么能访问ID为利用规划环境地政司的每个项目。 不幸的是,创建自定义密钥生成器将无济于事,因为它们都基于参数,目标类和方法。
有什么建议吗?