3
我們有一個使用的Oracle Coherence 3.5 L1/L2高速緩存重(1K請求/秒),其中性能是至關重要的一個多線程應用程序...Oracle Coherence的CacheFactory.getCache()的用法
我是否需要同步訪問
CacheFactory.getCache()
?我應該重複使用
NamedCache
後續請求的結果嗎?
目前其執行以下操作,以儘量減少對CacheFactory通話和同步訪問它...
static ConcurrentHashMap<String, NamedCache> cacheMap = new ConcurrentHashMap<String, NamedCache>();
protected static NamedCache getCache(String cacheName)
{
NamedCache cache = cacheMap.get(cacheName);
if (cache == null)
{
cache = CacheFactory.getCache(cacheName);
cacheMap.put(cacheName, cache);
}
return cache;
}
UPDATE:張望了一下後戳,這似乎是不必要的,因爲被認爲連貫性的API要線程安全...似乎我可以簡化到這一點,對嗎?
protected static NamedCache getCache(String cacheName)
{
return CacheFactory.getCache(cacheName);
}