首页 文章

使用ehcache缓存java.util.Map

提问于
浏览
0

我'm using EHCache with Hibernate to cache my DB query results. I' m使用谷歌注释( com.googlecode.ehcache.annotations.Cacheable )使DAO方法可缓存 .

我的问题是,该方法中的一个参数是 java.util.Map ,我不知道如何缓存它?

示例代码:

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

这是示例方法

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

有帮助吗?

1 回答

  • 1

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

相关问题