【发布时间】:2017-12-07 13:21:02
【问题描述】:
我们要求每个 userId-sessionID 对最多缓存 2 个类别的请求。我们计划将 EhCache 用于这种方法。该项目是一个 Spring Boot 应用程序。
@Cacheable(value="products")
ProductList getProducts(String userID, String sessionID, String categoryID) {
return getProductListForThisUserAndSessionAndCategory(userId, sessionId, categoryId;)
}
问题是,当每个用户和会话 ID 对可能有多个类别时,如何将限制设置为每个 userID-sessionId 最多 2 个缓存元素?
一种方法:
设置 sessionId 和 userID 的部分键并创建一个自定义缓存,每个 sessionID-userID 键最多可以接受两个值。 EhCache 如何支持自定义缓存?
还有其他方法吗?
【问题讨论】:
标签: java spring-boot ehcache-3