public class ConcurrentDataCache extends AbstractDataCache implements RemoteCommitListener
DataCache implementation that is optimized for concurrent
access. When the cache fills up, values to remove from cache are chosen
randomly. Due to race conditions, it is possible that a get call might not
return a cached instance if that instance is being transferred between
internal datastructures.| Modifier and Type | Field and Description |
|---|---|
protected boolean |
_lru |
_evictOnBulkUpdate, _excludedTypes, _includedTypes, _stats, conf, log_listenersNAME_DEFAULT| Constructor and Description |
|---|
ConcurrentDataCache() |
| 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.
|
protected DataCachePCData |
getInternal(Object key)
Return the object for the given oid.
|
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 CacheMap |
newCacheMap()
Return the map to use as an internal cache; entry expirations must
invoke
AbstractDataCache.keyRemoved(java.lang.Object, boolean). |
protected boolean |
pinInternal(Object key)
Pin an object to the cache.
|
protected DataCachePCData |
putInternal(Object key,
DataCachePCData pc)
Add the given object to the cache, returning the old object under the
given oid.
|
protected boolean |
recacheUpdates()
Return
true if updates to data already in the
cache (either in AbstractDataCache.commit(java.util.Collection<org.apache.openjpa.datacache.DataCachePCData>, java.util.Collection<org.apache.openjpa.datacache.DataCachePCData>, java.util.Collection<org.apache.openjpa.datacache.DataCachePCData>, java.util.Collection<java.lang.Object>) or the AbstractDataCache.update(org.apache.openjpa.datacache.DataCachePCData))
should be put back into the cache. |
protected void |
removeAllInternal(Class<?> cls,
boolean subs)
Evict objects in cache by class.
|
protected DataCachePCData |
removeInternal(Object key)
Remove the object under the given oid 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.
|
void |
unpinAll(Class<?> cls,
boolean subs)
Unpin all oids associaed with the given type from the cache.
|
protected boolean |
unpinInternal(Object key)
Unpin an object from the cache.
|
void |
writeLock()
Obtain a write lock on the cache.
|
void |
writeUnlock()
Release the write lock on the cache.
|
addExpirationListener, afterCommit, clear, close, close, commit, contains, containsAll, endConfiguration, fireEvent, get, getAll, getEnableStatistics, getEvictionSchedule, getEvictOnBulkUpdate, getExcludedTypes, getName, getPartition, getPartitionNames, getStatistics, getTypes, isClosed, isPartitioned, keyRemoved, pin, pinAll, pinAll, put, putAllInternal, remove, removeAll, removeAll, removeAllInternal, removeAllTypeNamesInternal, removeExpirationListener, selectCache, setConfiguration, setEnableStatistics, setEvictionSchedule, setEvictOnBulkUpdate, setExcludedTypes, setExcludedTypes, setName, setTypes, setTypes, startConfiguration, toString, unpin, unpinAll, updateaddListener, fireEvent, getListeners, hasListener, hasListeners, isFailFast, newListenerCollection, removeListener, setFailFastclone, equals, finalize, getClass, hashCode, notify, notifyAll, 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.public void setCacheSize(int size)
size, then this method will result in the cache
flushing old values.public int getCacheSize()
public void setSoftReferenceSize(int size)
size, then this method will result in the cache
flushing values.public int getSoftReferenceSize()
-1.public void initialize(DataCacheManager mgr)
DataCacheDataCacheManager.initialize in interface DataCacheinitialize in class AbstractDataCachepublic void unpinAll(Class<?> cls, boolean subs)
DataCacheunpinAll in interface DataCacheunpinAll in class AbstractDataCachesubs - Whether to include subclasses.public void writeLock()
DataCachepublic void writeUnlock()
DataCachewriteUnlock in interface DataCacheprotected CacheMap newCacheMap()
AbstractDataCache.keyRemoved(java.lang.Object, boolean).protected DataCachePCData getInternal(Object key)
AbstractDataCachegetInternal in class AbstractDataCacheprotected DataCachePCData putInternal(Object key, DataCachePCData pc)
AbstractDataCacheputInternal in class AbstractDataCacheprotected DataCachePCData removeInternal(Object key)
AbstractDataCacheremoveInternal in class AbstractDataCacheprotected void removeAllInternal(Class<?> cls, boolean subs)
AbstractDataCacheremoveAllInternal in class AbstractDataCacheprotected void clearInternal()
AbstractDataCacheclearInternal in class AbstractDataCacheprotected boolean pinInternal(Object key)
AbstractDataCachepinInternal in class AbstractDataCacheprotected boolean unpinInternal(Object key)
AbstractDataCacheunpinInternal in class AbstractDataCacheprotected boolean recacheUpdates()
AbstractDataCachetrue if updates to data already in the
cache (either in AbstractDataCache.commit(java.util.Collection<org.apache.openjpa.datacache.DataCachePCData>, java.util.Collection<org.apache.openjpa.datacache.DataCachePCData>, java.util.Collection<org.apache.openjpa.datacache.DataCachePCData>, java.util.Collection<java.lang.Object>) or the AbstractDataCache.update(org.apache.openjpa.datacache.DataCachePCData))
should be put back into the cache. Returns false by default.recacheUpdates in class AbstractDataCachepublic void setLru(boolean l)
public boolean getLru()
Copyright © 2006–2020 Apache Software Foundation. All rights reserved.