I'm using Spring 3.1 and I want to use the new cache features. Then, I tried:
<cache:annotation-driven />
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager"
p:cache-manager-ref="ehcache" />
<!-- Ehcache library setup -->
<bean id="ehcache"
class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"
p:config-location="classpath:ehcache.xml" />
But I didn't find the way to configure my custom KeyGenerator. Any idea?
There is a better way in Spring 3.1 RC1:
As of today just delete the org.springframework.context.support-3.1.0.RC1.jar\org\springframework\cache\config\spring-cache-3.1.xsd from the jar file you get when you download spring and it works fine.
I encountered a problem with Spring Frameworks default Cache KeyGenerator. It seems to often encounter conflicts and it appears to have been recorded on this issue
I know this question has already been marked as answered, but I thought I would share how I resolved this...
Basically, we created and used our own Cache KeyGenerator in place of the default one.
Ok, I just find a way to do this...
As you can see, I use the AnnotationDrivenCacheBeanDefinitionParser, I put the configuration in my xml, and it works :) Done!
edit:
For Spring > 3.2, you can use a simple Java class configuration implementing CachingConfigurer: