【发布时间】:2011-12-17 14:58:02
【问题描述】:
我正在使用 EHCache 和 Hibernate 来缓存我的数据库查询结果。
我正在使用 google annotations(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
}
有什么帮助吗?
【问题讨论】:
标签: java hibernate spring ehcache