Sep 5th, 2012, 12:43 PM
Cache abstraction - configurable KeyGenerator per method
I have noticed that I can change default cache KeyGenerator implementation by setting key-generator attribute on <cache:annotation-driven> element. Is there any way to set custom KeyGenerator per method?
My use case is:
In a project, default KeyGenerator (based on parameters) is ok for most methods. But there are methods I want to cache per user (user is stored in ThreadLocal). Hence I need different KeyGenerator implementations for different methods.
Key generators are configurable per @Cacheable annotation in the ehcache-spring-annotations project. Can I do simmilar thing in Spring 3.1 cache abstraction?