Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.openjpa.datacache
Class ConcurrentDataCache

    java.lang.Object
      org.apache.openjpa.lib.util.concurrent.AbstractConcurrentEventManager
          org.apache.openjpa.datacache.AbstractDataCache
              org.apache.openjpa.datacache.ConcurrentDataCache

All Implemented Interfaces:
  Serializable, DataCache, RemoteCommitListener, Configurable, Clearable, Closeable, EventManager

Direct Known Subclasses:
  PartitionedDataCache

    public class ConcurrentDataCache

extends AbstractDataCache
implements RemoteCommitListener

A `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.

Since:
  0.4.0
See Also:
  Serialized Form

Field Summary
`protected boolean` | `_lru`

Fields inherited from class org.apache.openjpa.datacache.AbstractDataCache
`_evictOnBulkUpdate, _excludedTypes, _includedTypes, _stats, conf, log`

Fields inherited from class org.apache.openjpa.lib.util.concurrent.AbstractConcurrentEventManager
`_listeners`

Fields inherited from interface org.apache.openjpa.datacache.DataCache
`NAME_DEFAULT`

Constructor Summary
`ConcurrentDataCache()`

Method Summary
`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, java.util.Collection, java.util.Collection, java.util.Collection)` 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.

Methods inherited from class org.apache.openjpa.datacache.AbstractDataCache
`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, update`

Methods inherited from class org.apache.openjpa.lib.util.concurrent.AbstractConcurrentEventManager
`addListener, fireEvent, getListeners, hasListener, hasListeners, isFailFast, newListenerCollection, removeListener, setFailFast`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface org.apache.openjpa.event.RemoteCommitListener
`afterCommit, close`

Field Detail

### _lru

    protected boolean _lru

Constructor Detail

### ConcurrentDataCache

    public ConcurrentDataCache()

Method Detail

### getCacheMap

    public CacheMap getCacheMap()

  Returns the underlying `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.

### setCacheSize

    public void setCacheSize(int size)

  Sets the maximum number of unpinned objects to keep hard references to. If the map contains more unpinned objects than `size`, then this method will result in the cache flushing old values.

### getCacheSize

    public int getCacheSize()

  Returns the maximum number of unpinned objects to keep hard references to.

### setSoftReferenceSize

    public void setSoftReferenceSize(int size)

  Sets the maximum number of unpinned objects to keep soft references to. If the map contains more soft references than `size`, then this method will result in the cache flushing values.

### getSoftReferenceSize

    public int getSoftReferenceSize()

  Returns the maximum number of unpinned objects to keep soft references to. Defaults to `-1`.

### initialize

    public void initialize(DataCacheManager mgr)

  Description copied from interface: `DataCache`
  Initialize any resources associated with the given `DataCacheManager`.

  Specified by:
    `initialize` in interface `DataCache`
  Overrides:
    `initialize` in class `AbstractDataCache`

### unpinAll

    public void unpinAll(Class<?> cls,
                         boolean subs)

  Description copied from interface: `DataCache`
  Unpin all oids associaed with the given type from the cache.

  Specified by:
    `unpinAll` in interface `DataCache`
  Overrides:
    `unpinAll` in class `AbstractDataCache`
    `subs` - Whether to include subclasses.

### writeLock

    public void writeLock()

  Description copied from interface: `DataCache`
  Obtain a write lock on the cache.

  Specified by:
    `writeLock` in interface `DataCache`

### writeUnlock

    public void writeUnlock()

  Description copied from interface: `DataCache`
  Release the write lock on the cache.

  Specified by:
    `writeUnlock` in interface `DataCache`

### newCacheMap

    protected CacheMap newCacheMap()

  Return the map to use as an internal cache; entry expirations must invoke `AbstractDataCache.keyRemoved(java.lang.Object, boolean)`.

### getInternal

    protected DataCachePCData getInternal(Object key)

  Description copied from class: `AbstractDataCache`
  Return the object for the given oid.

  Specified by:
    `getInternal` in class `AbstractDataCache`

### putInternal

    protected DataCachePCData putInternal(Object key,
                                          DataCachePCData pc)

  Description copied from class: `AbstractDataCache`
  Add the given object to the cache, returning the old object under the given oid.

  Specified by:
    `putInternal` in class `AbstractDataCache`

### removeInternal

    protected DataCachePCData removeInternal(Object key)

  Description copied from class: `AbstractDataCache`
  Remove the object under the given oid from the cache.

  Specified by:
    `removeInternal` in class `AbstractDataCache`

### removeAllInternal

    protected void removeAllInternal(Class<?> cls,
                                     boolean subs)

  Description copied from class: `AbstractDataCache`
  Evict objects in cache by class.

  Specified by:
    `removeAllInternal` in class `AbstractDataCache`

### clearInternal

    protected void clearInternal()

  Description copied from class: `AbstractDataCache`
  Clear the cache.

  Specified by:
    `clearInternal` in class `AbstractDataCache`

### pinInternal

    protected boolean pinInternal(Object key)

  Description copied from class: `AbstractDataCache`
  Pin an object to the cache.

  Specified by:
    `pinInternal` in class `AbstractDataCache`

### unpinInternal

    protected boolean unpinInternal(Object key)

  Description copied from class: `AbstractDataCache`
  Unpin an object from the cache.

  Specified by:
    `unpinInternal` in class `AbstractDataCache`

### recacheUpdates

    protected boolean recacheUpdates()

  Description copied from class: `AbstractDataCache`
  Return `true` if updates to data already in the cache (either in `AbstractDataCache.commit(java.util.Collection, java.util.Collection, java.util.Collection, java.util.Collection)` or the `AbstractDataCache.update(org.apache.openjpa.datacache.DataCachePCData)`) should be put back into the cache. Returns false by default.

  Overrides:
    `recacheUpdates` in class `AbstractDataCache`

### setLru

    public void setLru(boolean l)

### getLru

    public boolean getLru()

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2006-2013 Apache Software Foundation. All Rights Reserved.