SolarMetric Kodo JDO 3.0.3 generated on February 20 2004

kodo.datacache
Class CacheImpl

java.lang.Object
  |
  +--kodo.datacache.AbstractCacheImpl
        |
        +--kodo.datacache.CacheImpl
All Implemented Interfaces:
com.solarmetric.util.Closeable, Configurable, DataCache, RemoteCommitListener, Watchable

public class CacheImpl
extends AbstractCacheImpl
implements RemoteCommitListener

A PersistenceManagerFactory cache implementation. Batch updates are performed atomically.


Fields inherited from class kodo.datacache.AbstractCacheImpl
cache, conf, log
 
Fields inherited from interface kodo.datacache.DataCache
DEFAULT_NAME
 
Constructor Summary
CacheImpl()
           
 
Method Summary
protected  boolean addExistingUpdates()
          Do nothing with the existing updates.
 void afterCommit(RemoteCommitEvent event)
          Notification that a transaction associated with a different PersistenceManagerFactory has successfully committed.
 void close()
          Close any resources used by this listener.
 void endConfiguration()
          Invoked upon completion of bean property configuration for this object.
 CacheMap getCacheMap()
          Returns the underlying CacheMap that this CacheImpl is using.
 int getCacheSize()
          Returns the maximum number of unpinned objects to keep hard references to.
 boolean getKeepSoftReferences()
          Returns whether or not this cache will keep soft references when objects expire.
 int getSoftReferenceSize()
          Returns the maximum number of unpinned objects to keep soft references to.
protected  Map newMap()
          Returns a new CacheMap for use as the underlying data cache.
 boolean pin(Object key)
          Pin the value stored under oid into the cache.
 void setCacheSize(int size)
          Sets the maximum number of unpinned objects to keep hard references to.
 void setKeepSoftReferences(boolean refs)
          Configures whether or not this cache will keep soft references when objects expire.
 void setSoftReferenceSize(int size)
          Sets the maximum number of unpinned objects to keep soft references to.
 boolean unpin(Object key)
          Unpin the value stored under oid into the cache.
 
Methods inherited from class kodo.datacache.AbstractCacheImpl
addListener, batchUpdate, clear, clearListeners, containsKey, get, getCacheStatisticsString, getHitCount, getMap, getMissCount, getName, getRecordCacheStatistics, getStatistics, keyRemoved, put, registerListener, remove, removeAll, removeListener, removeListener, setConfiguration, setName, setRecordCacheStatistics, startConfiguration, toString, updateValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CacheImpl

public CacheImpl()
Method Detail

getCacheMap

public CacheMap getCacheMap()

Returns the underlying CacheMap that this CacheImpl is using. This is not an unmodifiable view on the map, so care should be taken with this reference. Implementations should probably not mess with 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.

setKeepSoftReferences

public void setKeepSoftReferences(boolean refs)
Configures whether or not this cache will keep soft references when objects expire. Defaults to true.

getKeepSoftReferences

public boolean getKeepSoftReferences()
Returns whether or not this cache will keep soft references when objects expire.

newMap

protected Map newMap()
Returns a new CacheMap for use as the underlying data cache. This implementation returns a CacheMap. To implement a more sophisticated caching strategy, override this method to return a subclass of CacheMap.
Overrides:
newMap in class AbstractCacheImpl

addExistingUpdates

protected boolean addExistingUpdates()
Do nothing with the existing updates. This relies on the fact that any existing PCDatas are objects retrieved by invoking get() on this object in an atomic (synchronized) fashion.
Overrides:
addExistingUpdates in class AbstractCacheImpl

pin

public boolean pin(Object key)
Description copied from interface: DataCache
Pin the value stored under oid into the cache. This method guarantees that oid's value will not be dropped by the caching algorithm. This method does not affect the behavior of DataCache.remove(java.lang.Object).
Following copied from interface: kodo.datacache.DataCache
Returns:
true if oid's value was pinned into the cache; false if the oid is not in the cache.

unpin

public boolean unpin(Object key)
Description copied from interface: DataCache
Unpin the value stored under oid into the cache. This method reverses a previous invocation of DataCache.pin(java.lang.Object). This method does not remove anything from the cache; it merely makes oid's value a candidate for flushing from the cache.
Following copied from interface: kodo.datacache.DataCache
Returns:
true if oid's value was unpinned from the cache; false if the oid is not in the cache.

close

public void close()
Description copied from interface: RemoteCommitListener
Close any resources used by this listener.
Specified by:
close in interface RemoteCommitListener
Overrides:
close in class AbstractCacheImpl

endConfiguration

public void endConfiguration()
Description copied from interface: Configurable
Invoked upon completion of bean property configuration for this object.
Overrides:
endConfiguration in class AbstractCacheImpl

afterCommit

public void afterCommit(RemoteCommitEvent event)
Description copied from interface: RemoteCommitListener
Notification that a transaction associated with a different PersistenceManagerFactory has successfully committed.
Specified by:
afterCommit in interface RemoteCommitListener

SolarMetric Kodo JDO 3.0.3 generated on February 20 2004

Copyright 2001,2002 SolarMetric, Inc. All Rights Reserved.