How to specify some default custom made keygenerators?

333 views
Skip to first unread message

csplrj

unread,
Jul 25, 2011, 6:45:50 AM7/25/11
to Ehcache Spring Annotations
I want to specify some default custom made keygenerators? How to
achieve the same

I found something relating to this but could not get the example to
understand it.
http://code.google.com/p/ehcache-spring-annotations/issues/list?cursor=1


How does Spring Ehcache annotations works? I mean does it
automatically uses ListCacheKeyGenerator for List and normal
HashCodeCacheKeyGenerator for normal Objects?

Thanks in advance

CSJakharia

Eric Dalquist

unread,
Jul 25, 2011, 11:32:10 AM7/25/11
to ehcache-sprin...@googlegroups.com
You can specify the default key generator on the <ehcache:annotation-driven /> element in your spring context file

<ehcache:annotation-driven default-cache-key-generator="myKeyGenerator"/>
<bean id="myKeyGenerator" class="com.example.cache.MyCustomCacheKeyGenerator"/>

If you don't ever specify a key generator anywhere HashCodeCacheKeyGenerator will be used. It generates a Java long value that represents a reasonable combination of the hash codes of the method and arguments. The ListCacheKeyGenerator for example generates a List object that contains the method and arguments and when the key is compared List.equals is used.

-Eric
Reply all
Reply to author
Forward
0 new messages