springcachingehcacheinvalidationspring-modules

How do I invalidate a single entry from springmodules method cache?


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.


Solution

  • 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