私は、スタンドアロン環境で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" />
ありがとう、 ray。
しかし、私はcache.getKeys()メソッドを持っていけません。 org.springframework.cache.Cacheを使用しています – rayman
解決策は見つかりましたか? infinispanキャッシュを反復処理する方法。私は鍵が必要です。 –
基礎となるプロバイダにキャストしましたか? –