简体   繁体   中英

Caching java.util.Map with ehcache

I'm using EHCache with Hibernate to cache my DB query results. I'm using google annotations( com.googlecode.ehcache.annotations.Cacheable ) to make DAO methods cacheable.

My problem is that, one of the argument in the method is a java.util.Map and I have no clue how to cache it?

Sample Code :

import com.googlecode.ehcache.annotations.Cacheable;
import com.googlecode.ehcache.annotations.KeyGenerator;
import com.googlecode.ehcache.annotations.PartialCacheKey;
import com.googlecode.ehcache.annotations.Property;

Here is the sample method

@Cacheable(cacheName = "ehcahe", keyGenerator = @KeyGenerator(name = "HashCodeCacheKeyGenerator", properties = @Property(name = "includeMethod", value = "false")))
public Object get( @PartialCacheKey Map map ) {
 //do something
}

Any help?

您可以实现自己的CacheKeyGenerator ,请参见FAQ ,问题7

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM