Class HeapCache<K,V>
- java.lang.Object
-
- org.cache2k.core.BaseCache<K,V>
-
- org.cache2k.core.HeapCache<K,V>
-
- All Implemented Interfaces:
AutoCloseable
,org.cache2k.Cache<K,V>
,InternalCache<K,V>
,InternalCacheCloseContext
,CanCheckIntegrity
,HeapCacheForEviction<K,V>
,TimerEventListener<K,V>
,org.cache2k.DataAware<K,V>
,org.cache2k.KeyValueSource<K,V>
- Direct Known Subclasses:
IntHeapCache
public class HeapCache<K,V> extends BaseCache<K,V> implements HeapCacheForEviction<K,V>
Foundation for all cache variants. All common functionality is in here. For a (in-memory) cache we need three things: a fast hash table implementation, an LRU list (a simple double linked list), and a fast timer. The variants implement different eviction strategies.Locking: The cache has a single structure lock obtained via
lock
and also locks on each entry for operations on it. Though, mutation operations that happen on a single entry get serialized.- Author:
- Jens Wilke
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
HeapCache.Tunable
-
Field Summary
Fields Modifier and Type Field Description protected long
clearCnt
Number of clear operations.protected long
clearedTime
protected long
clearRemovedCnt
Number of entries removed by clear.protected org.cache2k.operation.TimeReference
clock
static org.cache2k.io.ExceptionPropagator
DEFAULT_EXCEPTION_PROPAGATOR
protected org.cache2k.io.ExceptionPropagator<K,V>
exceptionPropagator
protected Hash2<K,V>
hash
protected org.cache2k.core.CacheBaseInfo
info
Statisticsprotected long
internalExceptionCnt
Number of internal exceptions.protected long
keyMutationCnt
Counts the number of key mutations.protected org.cache2k.config.CacheType
keyType
protected org.cache2k.io.AdvancedCacheLoader<K,V>
loader
Object
lock
Structure lock of the cache.CacheManagerImpl
manager
protected String
name
protected long
startedTime
protected Timing<K,V>
timing
static HeapCache.Tunable
TUNABLE
protected org.cache2k.config.CacheType
valueType
-
Constructor Summary
Constructors Constructor Description HeapCache(InternalCacheBuildContext<K,V> ctx)
called from CacheBuilder
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cancelTimerJobs()
Preparation for shutdown.Set<K>
checkAllPresent(Iterable<? extends K> keys)
Checks for entries being present and fresh.void
checkClosed()
void
checkIntegrity()
Check internal data structures and throw and exception if something is wrong, used for unit testingvoid
clear()
void
clearLocalCache()
void
close()
void
closePart1()
void
closePart2(InternalCache userCache)
V
computeIfAbsent(K key, Function<? super K,? extends V> function)
Code duplicates withCache.get(Object)
boolean
containsAndRemove(K key)
boolean
containsKey(K key)
Map<K,V>
convertCacheEntry2ValueMap(Map<K,org.cache2k.CacheEntry<K,V>> map)
Map<K,V>
convertValueMap(Map<K,V> map)
protected <R> EntryAction<K,V,R>
createEntryAction(K key, Entry<K,V> e, Semantic<K,V,R> op)
protected <R> org.cache2k.core.HeapCache.MyEntryAction<R>
createFireAndForgetAction(Entry<K,V> e, Semantic<K,V,R> op)
Hash2<K,V>
createHashTable()
void
executeLoader(Runnable r)
Execute with loader executor and back pressure.<T> T
executeWithGlobalLock(Supplier<T> job)
Execute job while making sure that no other operations are going on.protected void
expireEntry(Entry<K,V> e)
K
extractIntKeyObj(K key)
The key object or null, for integer keyed cachesint
extractIntKeyValue(K key, int hc)
Modified hash code or integer value for integer keyed cachesK
extractKeyObj(Entry<K,V> e)
int
extractModifiedHash(Entry e)
protected void
finishLoadOrEviction(Entry<K,V> e, long nextRefreshTime)
static <K> Set<K>
generateKeySet(Iterable<? extends K> keys)
Generate a set of unique keys from the iterable.V
get(K key)
Map<K,V>
getAll(Iterable<? extends K> inputKeys)
JSR107 bulk interface.org.cache2k.CacheManager
getCacheManager()
The cache managerorg.cache2k.operation.TimeReference
getClock()
Time reference for the cache.CommonMetrics
getCommonMetrics()
String
getCompleteName()
Returns name of the cache with manager name.org.cache2k.CacheEntry<K,V>
getEntry(K key)
protected Entry<K,V>
getEntryInternal(K key)
protected Entry<K,V>
getEntryInternal(K key, int hc, int val)
String
getEntryState(K key)
Eviction
getEviction()
Executor
getExecutor()
Entry<K,V>[]
getHashEntries()
Hash table entry array, used reaa only by random eviction.InternalCacheInfo
getInfo()
Generate cache statistics.InternalCacheInfo
getInfo(InternalCache userCache)
protected IntegrityState
getIntegrityState()
org.cache2k.config.CacheType
getKeyType()
InternalCacheInfo
getLatestInfo()
Generate fresh statistics.InternalCacheInfo
getLatestInfo(InternalCache userCache)
Executor
getLoaderExecutor()
long
getLocalSize()
Log
getLog()
Normally a cache itself logs nothing, so just construct when needed.String
getName()
Designation of target for logging and exceptions.Executor
getRefreshExecutor()
Timing<K,V>
getTiming()
Used for testsint
getTotalEntryCount()
This method is used forConcurrentMapWrapper.size()
org.cache2k.config.CacheType
getValueType()
void
init()
void
initWithoutTimerHandler()
protected void
insert(Entry<K,V> e, V value, long t0, long t, long refreshTime, byte updateStatistics, long nextRefreshTime)
protected Entry<K,V>
insertNewEntry(K key, int hc, int val)
Insert new entry in all structures (hash and eviction).protected void
insertOrUpdateAndCalculateExpiry(Entry<K,V> e, V v, long t0, long t, long refreshTime, byte updateStatistics)
Calculate the next refresh time if a timer / expiry is needed and call insert.<R> R
invoke(K key, org.cache2k.processor.EntryProcessor<K,V,R> processor)
Simply theEntryAction
based code to provide the entry processor.boolean
isClosed()
protected boolean
isKeepAfterExpired()
boolean
isLoaderPresent()
boolean
isNullValuePermitted()
protected boolean
isRecordRefreshTime()
boolean
isRefreshAhead()
protected boolean
isRejectNullValues()
protected boolean
isUpdateTimeNeeded()
No need to update the entry last modification time.boolean
isWeigherPresent()
ConcurrentEntryIterator<K,V>
iterateAllHeapEntries()
Returns all cache entries within the heap cache.Iterator<org.cache2k.CacheEntry<K,V>>
iterator()
protected void
load(Entry<K,V> e)
CompletableFuture<Void>
loadAll(Iterable<? extends K> keys)
protected Entry<K,V>
loadAndReplace(K key)
Always fetch the value from the source.void
logAndCountInternalException(String text, Throwable exception)
protected Entry<K,V>
lookupEntry(K key)
protected Entry<K,V>
lookupEntry(K key, int hc, int val)
protected Entry<K,V>
lookupEntryNoHitRecord(K key)
protected Entry<K,V>
lookupEntryNoHitRecord(K key, int hc, int val)
protected Entry<K,V>
lookupOrNewEntry(K key)
Lookup or create a new entry.protected Entry<K,V>
lookupOrNewEntry(K key, int hc, int val)
protected Entry<K,V>
lookupOrNewEntryNoHitRecord(K key)
static int
modifiedHash(int h)
This function calculates a modified hash code.V
peek(K key)
Map<K,V>
peekAll(Iterable<? extends K> inputKeys)
V
peekAndPut(K key, V value)
V
peekAndRemove(K key)
V
peekAndReplace(K key, V value)
org.cache2k.CacheEntry<K,V>
peekEntry(K key)
protected Entry<K,V>
peekEntryInternal(K key)
Return the entry, if it is in the cache, without invoking the cache source.protected Entry<K,V>
peekEntryInternal(K key, int hc, int val)
void
put(K key, V value)
void
putAll(Map<? extends K,? extends V> valueMap)
boolean
putIfAbsent(K key, V value)
protected void
putValue(Entry<K,V> e, V value)
Update the value directly within entry lock.protected void
recordHit(Entry e)
Increment the hit counter, because entry was accessed.CompletableFuture<Void>
reloadAll(Iterable<? extends K> keys)
void
remove(K key)
protected boolean
removeEntry(Entry<K,V> e)
Remove the entry from the hash and the replacement list.void
removeEntryForEviction(Entry<K,V> e)
Remove the entry from the hash table.boolean
removeIfEquals(K key, V value)
Remove the object from the cache.protected boolean
replace(K key, boolean compare, V oldValue, V newValue)
replace if value matches.boolean
replace(K key, V newValue)
boolean
replaceIfEquals(K key, V oldValue, V newValue)
org.cache2k.CacheEntry<K,V>
returnCacheEntry(K key, V valueOrException)
org.cache2k.CacheEntry<K,V>
returnCacheEntry(ExaminationEntry<K,V> entry)
protected org.cache2k.CacheEntry<K,V>
returnEntry(ExaminationEntry<K,V> e)
Wrap entry in a separate object instance.RuntimeException
returnNullValueDetectedException()
protected V
returnValue(Entry<K,V> e)
static <V> V
returnValue(V v)
void
setTiming(Timing<K,V> rh)
void
startRefreshProbationTimer(Entry<K,V> e, long nextRefreshTime)
void
timerEventExpireEntry(Entry<K,V> e, Object task)
Called by the timer when an entry is expired or before actual expiry when the entry needs to switch into sharp expiry mode.void
timerEventProbationTerminated(Entry<K,V> e, Object task)
void
timerEventRefresh(Entry<K,V> e, Object task)
The entry should be refreshed.-
Methods inherited from class org.cache2k.core.BaseCache
asMap, closeCustomization, entries, execute, execute, expireAt, invokeAll, keys, nameQualifier, removeAll, removeAll, requestInterface, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.cache2k.core.api.InternalCache
getUserCache
-
-
-
-
Field Detail
-
TUNABLE
public static final HeapCache.Tunable TUNABLE
-
DEFAULT_EXCEPTION_PROPAGATOR
public static final org.cache2k.io.ExceptionPropagator DEFAULT_EXCEPTION_PROPAGATOR
-
name
protected final String name
-
manager
public final CacheManagerImpl manager
-
clock
protected org.cache2k.operation.TimeReference clock
-
lock
public final Object lock
Structure lock of the cache. Every operation that needs a consistent structure of the cache or modifies it needs to synchronize on this. Since this is a global lock, locking on it should be avoided and any operation under the lock should be quick.
-
info
protected org.cache2k.core.CacheBaseInfo info
Statistics
-
keyMutationCnt
protected volatile long keyMutationCnt
Counts the number of key mutations. The count is not guarded and racy, but does not need to be exact. We don't put it to the metrics, because we do not want to have this disabled.
-
clearedTime
protected long clearedTime
-
startedTime
protected long startedTime
-
clearRemovedCnt
protected long clearRemovedCnt
Number of entries removed by clear. Guarded by: lock
-
clearCnt
protected long clearCnt
Number of clear operations. Guarded by: lock
-
internalExceptionCnt
protected long internalExceptionCnt
Number of internal exceptions. Guarded by: lock.
-
keyType
protected org.cache2k.config.CacheType keyType
-
valueType
protected org.cache2k.config.CacheType valueType
-
-
Constructor Detail
-
HeapCache
public HeapCache(InternalCacheBuildContext<K,V> ctx)
called from CacheBuilder
-
-
Method Detail
-
getLoaderExecutor
public Executor getLoaderExecutor()
-
isKeepAfterExpired
protected final boolean isKeepAfterExpired()
-
isRejectNullValues
protected final boolean isRejectNullValues()
-
isNullValuePermitted
public final boolean isNullValuePermitted()
- Specified by:
isNullValuePermitted
in interfaceInternalCache<K,V>
-
isRefreshAhead
public final boolean isRefreshAhead()
-
isUpdateTimeNeeded
protected final boolean isUpdateTimeNeeded()
No need to update the entry last modification time. False, if no time dependent expiry calculations are done.
-
isRecordRefreshTime
protected final boolean isRecordRefreshTime()
-
getCompleteName
public String getCompleteName()
Returns name of the cache with manager name.- See Also:
similar
-
getLog
public Log getLog()
Normally a cache itself logs nothing, so just construct when needed. Not requesting the log at startup means that the potential log target is not showing up in some management interfaces. This is intentional, since if caches are created and closed dynamically, we would have a memory leak, since logs can not be closed.- Specified by:
getLog
in interfaceInternalCache<K,V>
-
getName
public String getName()
Description copied from interface:TimerEventListener
Designation of target for logging and exceptions.- Specified by:
getName
in interfaceorg.cache2k.Cache<K,V>
- Specified by:
getName
in interfaceInternalCacheCloseContext
- Specified by:
getName
in interfaceTimerEventListener<K,V>
-
getKeyType
public org.cache2k.config.CacheType getKeyType()
- Specified by:
getKeyType
in interfaceInternalCache<K,V>
-
getValueType
public org.cache2k.config.CacheType getValueType()
- Specified by:
getValueType
in interfaceInternalCache<K,V>
-
init
public void init()
-
initWithoutTimerHandler
public void initWithoutTimerHandler()
-
checkClosed
public void checkClosed()
-
clearLocalCache
public final void clearLocalCache()
-
cancelTimerJobs
public void cancelTimerJobs()
Preparation for shutdown. Cancel all pending timer jobs e.g. for expiry/refresh or flushing the storage.- Specified by:
cancelTimerJobs
in interfaceInternalCache<K,V>
-
closePart1
public void closePart1() throws CacheClosedException
- Throws:
CacheClosedException
- if cache is closed or closing is initiated by another thread.
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceorg.cache2k.Cache<K,V>
-
closePart2
public void closePart2(InternalCache userCache)
-
recordHit
protected void recordHit(Entry e)
Increment the hit counter, because entry was accessed.The hit counter is a dirty counter. In case of multiple CPU cores incrementing the same entry counter, increments will be lost. For the functionality of the eviction algorithm this is not a real loss, since still the most accessed entries will have more counts then the others. On 32 bit systems word tearing may occur. This will also have no real observable negative impact on the eviction, so we do not compensate for it.
The hit count is also used for access statistics. The dirty counting will effect the exact correctness of the access statistics.
Using a 64 bit counter per entry is basically a big waste of memory. When reducing to a 32 bit value is has approximately a negative performance impact of 30%.
-
returnEntry
protected org.cache2k.CacheEntry<K,V> returnEntry(ExaminationEntry<K,V> e)
Wrap entry in a separate object instance. We can return the entry directly, however we lock on the entry object.
-
getEntryState
public String getEntryState(K key)
- Specified by:
getEntryState
in interfaceInternalCache<K,V>
-
returnCacheEntry
public org.cache2k.CacheEntry<K,V> returnCacheEntry(ExaminationEntry<K,V> entry)
- Specified by:
returnCacheEntry
in interfaceInternalCache<K,V>
-
removeEntry
protected boolean removeEntry(Entry<K,V> e)
Remove the entry from the hash and the replacement list. There is a race condition to catch: The eviction may run in a parallel thread and may have already selected this entry.
-
putValue
protected final void putValue(Entry<K,V> e, V value)
Update the value directly within entry lock. Since we did not start entry processing we do not need to notify any waiting threads.
-
replace
protected boolean replace(K key, boolean compare, V oldValue, V newValue)
replace if value matches. if value not matches, return the existing entry or the dummy entry.
-
peekEntryInternal
protected final Entry<K,V> peekEntryInternal(K key)
Return the entry, if it is in the cache, without invoking the cache source.The cache storage is asked whether the entry is present. If the entry is not present, this result is cached in the local cache.
-
containsKey
public boolean containsKey(K key)
-
computeIfAbsent
public V computeIfAbsent(K key, Function<? super K,? extends V> function)
Code duplicates withCache.get(Object)
-
containsAndRemove
public boolean containsAndRemove(K key)
-
getRefreshExecutor
public Executor getRefreshExecutor()
-
loadAll
public CompletableFuture<Void> loadAll(Iterable<? extends K> keys)
-
reloadAll
public CompletableFuture<Void> reloadAll(Iterable<? extends K> keys)
-
executeLoader
public void executeLoader(Runnable r)
Execute with loader executor and back pressure. In case the execution is rejected because there are not enough threads available, the task is executed in the calling thread to produce back pressure. If callers should never block upon aloadAll
the executor must have a unbound queue.
-
generateKeySet
public static <K> Set<K> generateKeySet(Iterable<? extends K> keys)
Generate a set of unique keys from the iterable. Optimize if its already a set or an collection.
-
checkAllPresent
public Set<K> checkAllPresent(Iterable<? extends K> keys)
Checks for entries being present and fresh. Used byloadAll
andprefetchAll
- Parameters:
keys
- keys to check for- Returns:
- keys not present in the cache
-
loadAndReplace
protected Entry<K,V> loadAndReplace(K key)
Always fetch the value from the source. That is a copy of getEntryInternal without freshness checks.
-
lookupOrNewEntry
protected Entry<K,V> lookupOrNewEntry(K key)
Lookup or create a new entry. The new entry is created, because we need it for locking within the data fetch.
-
returnValue
public static <V> V returnValue(V v)
-
insertNewEntry
protected Entry<K,V> insertNewEntry(K key, int hc, int val)
Insert new entry in all structures (hash and eviction). The insert at the eviction needs to be done under the same lock, to allow a check of the consistency.
-
getHashEntries
public Entry<K,V>[] getHashEntries()
Description copied from interface:HeapCacheForEviction
Hash table entry array, used reaa only by random eviction.- Specified by:
getHashEntries
in interfaceHeapCacheForEviction<K,V>
-
removeEntryForEviction
public void removeEntryForEviction(Entry<K,V> e)
Remove the entry from the hash table. The entry is already removed from the replacement list. Stop the timer, if needed. The remove races with a clear. The clear is not updating each entry state to e.isGone() but just drops the whole hash table instead.With completion of the method the entry content is no more visible. "Nulling" out the key or value of the entry is incorrect, since there can be another thread which is just about to return the entry contents.
- Specified by:
removeEntryForEviction
in interfaceHeapCacheForEviction<K,V>
-
isLoaderPresent
public boolean isLoaderPresent()
- Specified by:
isLoaderPresent
in interfaceInternalCache<K,V>
-
isWeigherPresent
public boolean isWeigherPresent()
- Specified by:
isWeigherPresent
in interfaceInternalCache<K,V>
-
insertOrUpdateAndCalculateExpiry
protected final void insertOrUpdateAndCalculateExpiry(Entry<K,V> e, V v, long t0, long t, long refreshTime, byte updateStatistics)
Calculate the next refresh time if a timer / expiry is needed and call insert.
-
returnNullValueDetectedException
public RuntimeException returnNullValueDetectedException()
-
insert
protected final void insert(Entry<K,V> e, V value, long t0, long t, long refreshTime, byte updateStatistics, long nextRefreshTime)
-
timerEventRefresh
public void timerEventRefresh(Entry<K,V> e, Object task)
Description copied from interface:TimerEventListener
The entry should be refreshed.- Specified by:
timerEventRefresh
in interfaceTimerEventListener<K,V>
- Parameters:
e
- seeTimerEventListener.timerEventExpireEntry(Entry, Object)
task
- seeTimerEventListener.timerEventExpireEntry(Entry, Object)
-
startRefreshProbationTimer
public void startRefreshProbationTimer(Entry<K,V> e, long nextRefreshTime)
-
timerEventProbationTerminated
public void timerEventProbationTerminated(Entry<K,V> e, Object task)
- Specified by:
timerEventProbationTerminated
in interfaceTimerEventListener<K,V>
- Parameters:
e
- seeTimerEventListener.timerEventExpireEntry(Entry, Object)
task
- seeTimerEventListener.timerEventExpireEntry(Entry, Object)
-
logAndCountInternalException
public void logAndCountInternalException(String text, Throwable exception)
- Specified by:
logAndCountInternalException
in interfaceInternalCache<K,V>
-
timerEventExpireEntry
public void timerEventExpireEntry(Entry<K,V> e, Object task)
Description copied from interface:TimerEventListener
Called by the timer when an entry is expired or before actual expiry when the entry needs to switch into sharp expiry mode. The actual action to be performed is detected by checking theEntry.getNextRefreshTime()
- Specified by:
timerEventExpireEntry
in interfaceTimerEventListener<K,V>
task
- timer task as returned byEntry.getTask()
to check whether the timer task is still valid after we obtained the entry lock
-
iterateAllHeapEntries
public final ConcurrentEntryIterator<K,V> iterateAllHeapEntries()
Returns all cache entries within the heap cache. Entries that are expired or contain no valid data are not filtered out.
-
getAll
public Map<K,V> getAll(Iterable<? extends K> inputKeys)
JSR107 bulk interface. The behaviour is compatible to the JSR107 TCK. We also need to be compatible to the exception handling policy, which says that the exception is to be thrown when most specific. So exceptions are only thrown, when the value which has produced an exception is requested from the map.
-
convertCacheEntry2ValueMap
public Map<K,V> convertCacheEntry2ValueMap(Map<K,org.cache2k.CacheEntry<K,V>> map)
-
createEntryAction
protected <R> EntryAction<K,V,R> createEntryAction(K key, Entry<K,V> e, Semantic<K,V,R> op)
- Specified by:
createEntryAction
in classBaseCache<K,V>
-
createFireAndForgetAction
protected <R> org.cache2k.core.HeapCache.MyEntryAction<R> createFireAndForgetAction(Entry<K,V> e, Semantic<K,V,R> op)
- Specified by:
createFireAndForgetAction
in classBaseCache<K,V>
-
getExecutor
public Executor getExecutor()
- Specified by:
getExecutor
in classBaseCache<K,V>
-
invoke
public <R> R invoke(K key, org.cache2k.processor.EntryProcessor<K,V,R> processor)
Simply theEntryAction
based 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.
-
getLocalSize
public final long getLocalSize()
-
getTotalEntryCount
public final int getTotalEntryCount()
Description copied from interface:InternalCache
This method is used forConcurrentMapWrapper.size()
- Specified by:
getTotalEntryCount
in interfaceInternalCache<K,V>
-
getIntegrityState
protected IntegrityState getIntegrityState()
-
checkIntegrity
public final void checkIntegrity()
Check internal data structures and throw and exception if something is wrong, used for unit testing- Specified by:
checkIntegrity
in interfaceCanCheckIntegrity
-
getInfo
public final InternalCacheInfo getInfo()
Description copied from interface:InternalCache
Generate cache statistics. Some of the statistic values involve scanning portions of the cache content. To prevent system stress e.g. monitoring there is a the compute intensive parts will only be repeated if some time is passed.- Specified by:
getInfo
in interfaceInternalCache<K,V>
-
getLatestInfo
public final InternalCacheInfo getLatestInfo()
Description copied from interface:InternalCache
Generate fresh statistics. This version is used by internal tests. This method is not intended to be called at high frequencies or for attaching monitoring or logging. Use theInternalCache.getInfo()
method for requesting information for monitoring.- Specified by:
getLatestInfo
in interfaceInternalCache<K,V>
-
getInfo
public final InternalCacheInfo getInfo(InternalCache userCache)
-
getLatestInfo
public final InternalCacheInfo getLatestInfo(InternalCache userCache)
-
getCommonMetrics
public CommonMetrics getCommonMetrics()
- Specified by:
getCommonMetrics
in interfaceInternalCache<K,V>
-
executeWithGlobalLock
public <T> T executeWithGlobalLock(Supplier<T> job)
Execute job while making sure that no other operations are going on. In case the eviction is connected via a queue we need to stop the queue processing. On the other hand we needs to make sure that the queue is drained because this method is used to access the recent statistics or check integrity. Draining the queue is a two phase job: The draining may not do eviction since we hold the locks, after lifting the lock with do eviction and lock again. This ensures that all queued entries are processed up to the point when the method was called.
-
getClock
public final org.cache2k.operation.TimeReference getClock()
Description copied from interface:InternalCache
Time reference for the cache.- Specified by:
getClock
in interfaceInternalCache<K,V>
-
getEviction
public final Eviction getEviction()
- Specified by:
getEviction
in interfaceInternalCache<K,V>
-
getCacheManager
public org.cache2k.CacheManager getCacheManager()
Description copied from interface:InternalCacheCloseContext
The cache manager- Specified by:
getCacheManager
in interfaceorg.cache2k.Cache<K,V>
- Specified by:
getCacheManager
in interfaceInternalCacheCloseContext
-
modifiedHash
public static int modifiedHash(int h)
This function calculates a modified hash code. The intention is to "rehash" the incoming integer hash codes to overcome weak hash code implementations. Identical to latest Java VMs.The mapping needs to be unique, so we can skip equals() check for integer key optimizations.
-
extractIntKeyValue
public int extractIntKeyValue(K key, int hc)
Modified hash code or integer value for integer keyed caches
-
extractModifiedHash
public int extractModifiedHash(Entry e)
-
-