Package org.cyclos.impl.utils.cache
Interface CacheHandler
-
- All Known Subinterfaces:
CacheHandlerImplementor
public interface CacheHandlerManages cache implementations
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidapply(TreeMap<CacheType<? extends Serializable,?>,CacheOperation> operations)Apply the given cache operations for eachCacheType.CustomCachecustom(String name)This method is intended to be used by scripts.<K extends Serializable,V>
Cache<K,V>getCache(CacheType<K,V> type)Returns theCacheimplementation for the given type<K extends Serializable,V>
Cache<K,V>getCacheIfInitialized(CacheType<K,V> type)Returns theCacheimplementation for the given type if it has already been initialized, or null otherwise<K extends Serializable,V>
voidscheduleClear(CacheType<K,V> type)Schedules a cache clear to be executed after the current transaction has been committed (important to prevent the cache from being reloaded by another thread before the current transaction is committed, populating the cache with a stale value)<K extends Serializable,V>
voidscheduleEvict(CacheType<K,V> type, Set<K> keys)Schedules the eviction of the given cache keys after the current transaction has been committed (important to prevent the cache from being reloaded by another thread before the current transaction is committed, populating the cache with a stale value)<K extends Serializable,V>
voidscheduleEvict(CacheType<K,V> type, K key)Schedules the eviction of an specific cache key after the current transaction has been committed (important to prevent the cache from being reloaded by another thread before the current transaction is committed, populating the cache with a stale value)<K extends Serializable,V>
voidschedulePartialEvict(CacheType<K,V> type, SerializablePredicate<K> predicate)Schedules the eviction of the keys matching the given predicate after the current transaction has been committed (important to prevent the cache from being reloaded by another thread before the current transaction is committed, populating the cache with a stale value)
-
-
-
Method Detail
-
apply
void apply(TreeMap<CacheType<? extends Serializable,?>,CacheOperation> operations)
Apply the given cache operations for eachCacheType.
-
custom
CustomCache custom(String name)
This method is intended to be used by scripts. Returns a custom cache for the given name. The returnedCacheis distinct fromgetCache(CacheType)andgetCacheIfInitialized(CacheType). The result is a proxy, in which calls to clear and evict methods will delegate toscheduleClear(CacheType),scheduleEvict(CacheType, Serializable), etc. This way the scripting API is more concise, like:def cache = cacheHandler.custom('myCustomCache') def value = cache.get('key', { 'value' }) cache.evict('key') // or cache.clear()
-
getCache
<K extends Serializable,V> Cache<K,V> getCache(CacheType<K,V> type)
Returns theCacheimplementation for the given type
-
getCacheIfInitialized
<K extends Serializable,V> Cache<K,V> getCacheIfInitialized(CacheType<K,V> type)
Returns theCacheimplementation for the given type if it has already been initialized, or null otherwise
-
scheduleClear
<K extends Serializable,V> void scheduleClear(CacheType<K,V> type)
Schedules a cache clear to be executed after the current transaction has been committed (important to prevent the cache from being reloaded by another thread before the current transaction is committed, populating the cache with a stale value)
-
scheduleEvict
<K extends Serializable,V> void scheduleEvict(CacheType<K,V> type, K key)
Schedules the eviction of an specific cache key after the current transaction has been committed (important to prevent the cache from being reloaded by another thread before the current transaction is committed, populating the cache with a stale value)
-
scheduleEvict
<K extends Serializable,V> void scheduleEvict(CacheType<K,V> type, Set<K> keys)
Schedules the eviction of the given cache keys after the current transaction has been committed (important to prevent the cache from being reloaded by another thread before the current transaction is committed, populating the cache with a stale value)
-
schedulePartialEvict
<K extends Serializable,V> void schedulePartialEvict(CacheType<K,V> type, SerializablePredicate<K> predicate)
Schedules the eviction of the keys matching the given predicate after the current transaction has been committed (important to prevent the cache from being reloaded by another thread before the current transaction is committed, populating the cache with a stale value)
-
-