4

We are using springmodules method caching (Spring 2.0.7) in combination with ehcache to cache data which is requested often, in order to take load from the database.

E.g. we are caching the method result of public Profile getUserProfile(User u) {...}: when the user updates data in his own profile, it would be nice to invalidate the cached Profile only for this single User directly after the update, so that the changes are reflected in the user interface right away.

Is there a way to achieve this without invalidating the complete cache for this method?

Or is there a better option than springmodules-caching for this use case?

Thanks a lot for any hints.

peterp
  • 3,101
  • 3
  • 22
  • 37

1 Answers1

2

Or is there a better option than springmodules-caching for this use case?

Use Spring 3.1 has this new cache feature.

How do I invalidate a single entry from springmodules method cache? By @CacheEvict from Spring 3.1

The Spring Reference for 3.1 has a nice chapter for this: 28.3 Declarative annotation-based caching

Ralph
  • 118,862
  • 56
  • 287
  • 383
  • Thanks for pointing me to Spring 3.1, looks like a neat way to achieve what I want. What I did not mention (sorry, just added this info) is that I am working on a pretty large project using Spring 2.0.7. Upgrading the project to Spring 3.1 would certainly need a lot of work. So if there is any other good solution (not necessarily a Spring solution), I would prefer this one... – peterp Mar 22 '12 at 10:45
  • @peterp: sorry I have no clue about this in Spring 2.0.7 and springmodules-caching – Ralph Mar 22 '12 at 10:47
  • Accepting this as it is the best answer, have not found another solution yet. Thanks Ralph – peterp Apr 26 '12 at 09:55