2011-11-10 65 views
0

我使用EHCache和Hibernate来缓存我的数据库查询结果。 我使用谷歌注释(com.googlecode.ehcache.annotations.Cacheable)使DAO方法可缓存。使用ehcache缓存java.util.Map

我的问题是,该方法中的一个参数是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

您可以实施您自己的CacheKeyGenerator,请参阅FAQ,问题7