Package org.cache2k.core
Class BaseCache<K,V>
- java.lang.Object
-
- org.cache2k.core.BaseCache<K,V>
-
- All Implemented Interfaces:
AutoCloseable,org.cache2k.Cache<K,V>,InternalCache<K,V>,InternalCacheCloseContext,TimerEventListener<K,V>,org.cache2k.DataAware<K,V>,org.cache2k.KeyValueSource<K,V>
- Direct Known Subclasses:
HeapCache,WiredCache
public abstract class BaseCache<K,V> extends Object implements InternalCache<K,V>
Some default implementations for a cache.- Author:
- Jens Wilke
-
-
Constructor Summary
Constructors Constructor Description BaseCache()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description ConcurrentMap<K,V>asMap()voidcloseCustomization(Object customization, String customizationName)Call close on the customization if theAutoCloseableinterface is implementedprotected abstract <R> EntryAction<K,V,R>createEntryAction(K key, Entry<K,V> e, Semantic<K,V,R> op)protected abstract <R> EntryAction<K,V,R>createFireAndForgetAction(Entry<K,V> e, Semantic<K,V,R> op)Set<org.cache2k.CacheEntry<K,V>>entries()protected <R> Rexecute(K key, Entry<K,V> e, Semantic<K,V,R> op)protected <R> Rexecute(K key, Semantic<K,V,R> op)voidexpireAt(K key, long time)abstract ExecutorgetExecutor()StringgetQualifiedName()Returns name of the cache with manager name.<R> Rinvoke(K key, org.cache2k.processor.EntryProcessor<K,V,R> processor)Simply theEntryActionbased code to provide the entry processor.<R> Map<K,org.cache2k.processor.EntryProcessingResult<R>>invokeAll(Iterable<? extends K> keys, org.cache2k.processor.EntryProcessor<K,V,R> entryProcessor)protected abstract Iterator<org.cache2k.CacheEntry<K,V>>iterator()Set<K>keys()Key iteration on top of normal iterator.voidremoveAll()voidremoveAll(Iterable<? extends K> keys)<X> XrequestInterface(Class<X> type)StringtoString()Return status information.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.cache2k.Cache
clear, close, computeIfAbsent, containsAndRemove, containsKey, get, getAll, getCacheManager, getEntry, getName, isClosed, loadAll, mutate, mutateAll, peek, peekAll, peekAndPut, peekAndRemove, peekAndReplace, peekEntry, put, putAll, putIfAbsent, reloadAll, remove, removeIfEquals, replace, replaceIfEquals
-
Methods inherited from interface org.cache2k.core.api.InternalCache
cancelTimerJobs, checkIntegrity, getClock, getCommonMetrics, getConsistentInfo, getEntryState, getEviction, getInfo, getKeyType, getLog, getTimeReference, getTiming, getTotalEntryCount, getUserCache, getValueType, isDisabled, isLoaderPresent, isNullValuePermitted, isWeigherPresent, logAndCountInternalException, returnCacheEntry, setDisabled
-
Methods inherited from interface org.cache2k.core.api.InternalCacheCloseContext
getCacheManager, getName
-
Methods inherited from interface org.cache2k.core.timing.TimerEventListener
getName, timerEventExpireEntry, timerEventProbationTerminated, timerEventRefresh
-
-
-
-
Method Detail
-
getExecutor
public abstract Executor getExecutor()
-
createFireAndForgetAction
protected abstract <R> EntryAction<K,V,R> createFireAndForgetAction(Entry<K,V> e, Semantic<K,V,R> op)
-
getQualifiedName
public String getQualifiedName()
Returns name of the cache with manager name.- Specified by:
getQualifiedNamein interfaceInternalCache<K,V>- See Also:
similar
-
requestInterface
public <X> X requestInterface(Class<X> type)
-
asMap
public ConcurrentMap<K,V> asMap()
-
invoke
public <R> R invoke(K key, org.cache2k.processor.EntryProcessor<K,V,R> processor)
Simply theEntryActionbased code to provide the entry processor. If we code it directly this might be a little bit more efficient, but it gives quite a code bloat which has lots of corner cases for loader and exception handling.
-
invokeAll
public <R> Map<K,org.cache2k.processor.EntryProcessingResult<R>> invokeAll(Iterable<? extends K> keys, org.cache2k.processor.EntryProcessor<K,V,R> entryProcessor)
-
expireAt
public void expireAt(K key, long time)
-
createEntryAction
protected abstract <R> EntryAction<K,V,R> createEntryAction(K key, Entry<K,V> e, Semantic<K,V,R> op)
-
closeCustomization
public void closeCustomization(Object customization, String customizationName)
Description copied from interface:InternalCacheCloseContextCall close on the customization if theAutoCloseableinterface is implemented- Specified by:
closeCustomizationin interfaceInternalCacheCloseContextcustomizationName- Name of customization like "expiryPolicy". This is used when an exception happens upon close.
-
-