Let's assume that I have a method that fetches data from Mongo which can be cached into redis.
@Cacheablepublic List<Values> cacheValues(List<String> input){ // code that fetches the list based on input from mongodb}
The problem is that there is a list of documents that corresponds to each particular input in mongo db. When fetched from mongo, all lists are merged into a single list. Is there any way we can tell the @Cacheable annotation that data has to be persisted and fetched in the same way? or is there any way we can customize the @Cacheable to be able to use our own redis operations for fetching and persisting?. I am using spring data redis.
2nd question: How can I create a key based the values in input. For example:
@Cacheable(cacheNames = "cach1", key = "input[0] +…. input[input.size-1]") public List<Values> cacheValues(List<String> input){ // code that fetches the list based on input from mongodb }