Class CacheUtils
java.lang.Object
ubic.gemma.persistence.cache.CacheUtils
Common helpers for Spring
Cache manipulation.
Pre-phase-2 this class branched per native cache type (EhCache 2 vs. Map vs. fallback).
Phase 2 retired EhCache 2 and reduced to "Map or generic Spring Cache fallback".
Phase 3 reintroduced a real CacheManager-backed Spring CacheManager
(EhcacheConfig), so the native cache is now a Cache (JSR-107)
for every application cache. The helpers below cover both backings:
Map (for tests / ad-hoc ConcurrentMapCache) and
Cache (production).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic CacheKeyLock.LockAcquisitionacquireReadLock(org.springframework.cache.Cache cache, Object key) static CacheKeyLock.LockAcquisitionacquireWriteLock(org.springframework.cache.Cache cache, Object key) static booleancontainsKey(org.springframework.cache.Cache cache, Object key) static voidEvict entries from the cache where the key matches a given predicate.static org.springframework.cache.Cachestatic Collection<?> getKeys(org.springframework.cache.Cache cache) static intgetSize(org.springframework.cache.Cache cache)
-
Constructor Details
-
CacheUtils
public CacheUtils()
-
-
Method Details
-
getCache
public static org.springframework.cache.Cache getCache(org.springframework.cache.CacheManager cacheManager, String cacheName) throws RuntimeException - Throws:
RuntimeException
-
getSize
public static int getSize(org.springframework.cache.Cache cache) -
containsKey
-
getKeys
-
evictIf
-
acquireReadLock
public static CacheKeyLock.LockAcquisition acquireReadLock(org.springframework.cache.Cache cache, Object key) throws InterruptedException - Throws:
InterruptedException
-
acquireWriteLock
public static CacheKeyLock.LockAcquisition acquireWriteLock(org.springframework.cache.Cache cache, Object key) throws InterruptedException - Throws:
InterruptedException
-