We have a requirement to Cache requests to a max of upto 2 categories per userId-sessionID pair. We are planning to use EhCache for this approach. The project is a spring boot application.
@Cacheable(value="products")
ProductList getProducts(String userID, String sessionID, String categoryID) {
return getProductListForThisUserAndSessionAndCategory(userId, sessionId, categoryId;)
}
The problem is how can I set the limit to a max of 2 cache elements per userID-sessionId when there could be more than one categories per user and session id pair?
One approach:
Setting a partial key of sessionId and userID and create a custom cache which can accept a max two values per sessionID-userID key. How does EhCache support custom Caches?
Any other approaches?