Hoping this is not a crazy question and that this is the right place to ask it...
I have two @service methods that return the same object out of MongoDB. They have different arguments - and I want to cache the returned object using the object's Id. E.g.,
Using @Cacheable I'm abale to easily cache the first one:Code:public User getUserById(String id) { ... public User getUserByEmailAddress(String emailAddress) { ...
I was hoping to use the @CachePut annotation to add caching to the second method - but I'm not sure how to extract the Id from the returned object:Code:@Cacheable(value = "user", key = "#id") public User getUserById(String id) { ...
Is there a way to do this through SpEL? Or do I need to roll my own Cache/Manager or Aspect as I have done in the past?Code:@CachePut(value = "user", key = ???) public User getUserByEmailAddress(String emailAddress) { ...
Thanks in advance.
M


Reply With Quote
