[英]Caching java.util.Map with ehcache
I'm using EHCache with Hibernate to cache my DB query results. 我将EHCache与Hibernate一起使用来缓存数据库查询结果。 I'm using google annotations(
com.googlecode.ehcache.annotations.Cacheable
) to make DAO methods cacheable. 我正在使用Google批注(
com.googlecode.ehcache.annotations.Cacheable
)使DAO方法可缓存。
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? 我的问题是,方法中的一个参数是
java.util.Map
,我不知道如何缓存它?
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.