public class ConcurrentQueryCache extends AbstractQueryCache implements RemoteCommitListener
QueryCache implementation that is optimized for concurrent
access. When the cache fill up, values to remove from the cache are chosen
randomly. Due to race conditions, it is possible that a get call might not
retur a cached instance if that instance is being transferred between
internal datastructures.AbstractQueryCache.Default<T>, AbstractQueryCache.EvictPolicy| Modifier and Type | Field and Description |
|---|---|
protected boolean |
_lru |
conf, entityTimestampMap, evictPolicy, log_listeners| Constructor and Description |
|---|
ConcurrentQueryCache() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
clearInternal()
Clear the cache.
|
CacheMap |
getCacheMap()
Returns the underlying
CacheMap that this cache is using. |
int |
getCacheSize()
Returns the maximum number of unpinned objects to keep hard
references to.
|
AbstractQueryCache.EvictPolicy |
getEvictPolicy()
Returns the eviction policy of the query cache
|
protected QueryResult |
getInternal(QueryKey qk)
Return the list for the given key.
|
boolean |
getLru() |
int |
getSoftReferenceSize()
Returns the maximum number of unpinned objects to keep soft
references to.
|
void |
initialize(DataCacheManager mgr)
Initialize any resources associated with the given
DataCacheManager. |
protected Collection |
keySet()
Return a threadsafe view of the keys in this cache.
|
protected CacheMap |
newCacheMap()
Return the map to use as an internal cache.
|
protected boolean |
pinInternal(QueryKey qk)
Pin an object to the cache.
|
protected QueryResult |
putInternal(QueryKey qk,
QueryResult result)
Add the given result to the cache, returning the old result under the
given key.
|
protected QueryResult |
removeInternal(QueryKey qk)
Remove the result under the given key from the cache.
|
void |
setCacheSize(int size)
Sets the maximum number of unpinned objects to keep hard
references to.
|
void |
setLru(boolean l) |
void |
setSoftReferenceSize(int size)
Sets the maximum number of unpinned objects to keep soft
references to.
|
protected boolean |
unpinInternal(QueryKey qk)
Unpin an object from the cache.
|
void |
writeLock()
Obtain a write lock on the cache.
|
void |
writeUnlock()
Release the write lock on the cache.
|
addTypesChangedListener, afterCommit, clear, close, close, count, endConfiguration, fireEvent, get, getAllEntityTimestamp, getEnableStatistics, getName, getStatistics, isClosed, newListenerCollection, onTypesChanged, pin, put, remove, removeAllInternal, removeTypesChangedListener, setConfiguration, setEnableStatistics, setEvictPolicy, setName, startConfiguration, unpin, updateEntityTimestampaddListener, fireEvent, getListeners, hasListener, hasListeners, isFailFast, removeListener, setFailFastclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitafterCommit, closepublic CacheMap getCacheMap()
CacheMap that this cache is using.
This is not an unmodifiable view on the map, so care should be taken
with this reference. Implementations should probably not modify the
contents of the cache, but should only use this reference
to obtain cache metrics. Additionally, this map may contain
expired data. Removal of timed-out data is done in a lazy
fashion, so the actual size of the map may be greater than the
number of non-expired query results in cache.public int getCacheSize()
public void setCacheSize(int size)
size, then this method will result in the cache
flushing old values.public int getSoftReferenceSize()
-1.public void setSoftReferenceSize(int size)
size, then this method will result in the cache
flushing values.public void initialize(DataCacheManager mgr)
QueryCacheDataCacheManager.initialize in interface QueryCacheinitialize in class AbstractQueryCachepublic void writeLock()
QueryCachewriteLock in interface QueryCachepublic void writeUnlock()
QueryCachewriteUnlock in interface QueryCacheprotected CacheMap newCacheMap()
protected QueryResult getInternal(QueryKey qk)
AbstractQueryCachegetInternal in class AbstractQueryCacheprotected QueryResult putInternal(QueryKey qk, QueryResult result)
AbstractQueryCacheputInternal in class AbstractQueryCacheprotected QueryResult removeInternal(QueryKey qk)
AbstractQueryCacheremoveInternal in class AbstractQueryCacheprotected void clearInternal()
AbstractQueryCacheclearInternal in class AbstractQueryCacheprotected boolean pinInternal(QueryKey qk)
AbstractQueryCachepinInternal in class AbstractQueryCacheprotected boolean unpinInternal(QueryKey qk)
AbstractQueryCacheunpinInternal in class AbstractQueryCacheprotected Collection keySet()
AbstractQueryCachekeySet in class AbstractQueryCachepublic AbstractQueryCache.EvictPolicy getEvictPolicy()
getEvictPolicy in class AbstractQueryCachepublic void setLru(boolean l)
public boolean getLru()
Copyright © 2006–2022 Apache Software Foundation. All rights reserved.