6
我在独立环境中使用Spring3.1。 我使用@Cachable批注缓存我的条目。如何迭代缓存条目
有时我需要迭代缓存列表才能获得特定值(非关键)。
所以我设法检索缓存列表,但我怎么能迭代它的元素。
private ClientDTO getClientDTOByClientId(Integer clientId)
{
Cache clientCache = null;
try
{
clientCache = ehCacheCacheManager.getCache("client");
//need here to iterate on clientCache. how?
}
catch (Exception e)
{
log.error("Couldnt retrieve client from cache. clientId=" + clientId);
}
return clientDTO;
}
我使用ehcache机制。
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager"
p:cache-manager-ref="ehcache" />
<bean id="ehcache"
class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"
p:config-location="classpath:ehcache.xml" />
谢谢, 射线。
但我没有cache.getKeys()方法。我正在使用org.springframework.cache.Cache – rayman 2012-08-06 14:16:29
您是否找到任何解决方案?如何迭代infinispan Cache。我需要钥匙。 – 2016-09-15 08:07:03
您是否投向底层提供商? – 2016-09-15 15:01:54