|
SolarMetric Kodo JDO 2.5.8 generated on January 11 2004 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--com.solarmetric.kodo.runtime.datacache.AbstractCacheImpl
Abstract DataCache implementation that provides various
locking, logging, etc. functionality common across cache
implementations.
| Field Summary | |
protected Map |
cache
A map in which that this cache implementation stores data. |
protected static org.apache.commons.logging.Log |
s_log
|
| Constructor Summary | |
AbstractCacheImpl()
|
|
| Method Summary | |
protected abstract boolean |
addExistingUpdates()
Return true if updates to data already in the
cache (either in batchUpdate(java.util.Collection, java.util.Collection, java.util.Collection, java.util.Collection) or the updateValue(com.solarmetric.kodo.runtime.PCData)) should be put back into the cache. |
void |
addExpirationListener(com.solarmetric.util.Listener listen)
Add a new expiration event listener to this cache. |
void |
batchUpdate(Collection additions,
Collection newUpdates,
Collection existingUpdates,
Collection deletes)
Perform a batch update of the cache. |
void |
clear()
Remove all data from this cache. |
void |
close()
Close this cache, dropping all hard references and releasing any resources that this cache maintains. |
boolean |
containsKey(Object key)
Returns true if this cache contains data
corresponding to key; otherwise returns
false. |
void |
endConfiguration()
Invoked upon completion of configuration of this object |
PCData |
get(Object key)
Return the cached object for the given key. |
String |
getCacheStatisticsString()
Returns a localized string containing the number of hits, the number of misses, and the hit ratio ( hits / (hits+misses)). |
int |
getHitCount()
Returns the number of cache hits for invocations of the get(java.lang.Object) method. |
Map |
getMap()
Returns the underlying Map that this
CacheImpl is using. |
int |
getMissCount()
Returns the number of cache misses for invocations of the get(java.lang.Object) method. |
String |
getName()
Returns a string name that can be used by end-user-visible code to identify this cache. |
boolean |
getRecordCacheStatistics()
Returns true if cache statistics recording is
currently on; otherwise returns false. |
boolean |
isDecorator()
Returns true if this cache is a decorator that
wraps another cache. |
protected void |
keyExpired(Object key)
Invoked when a key is expired from this cache. |
protected abstract Map |
newMap()
Returns a new Map for use as the underlying data
cache. |
PCData |
put(PCData data)
Set the cached value for the given key. |
PCData |
remove(Object key)
Remove the value stored under the given key. |
void |
removeAll(Collection keys)
|
DataCache |
removeDecorator()
Returns an undecorated version of this cache. |
DataCache |
removeDecorators()
Returns the lowest cache in the chain of caches in this object. |
void |
removeExpirationListener(com.solarmetric.util.Listener listen)
Remove an expiration event listener from this cache. |
void |
setName(String name)
Sets a string name to be used to identify this cache to end-user needs. |
void |
setRecordCacheStatistics(boolean record)
Turns cache statistics recording on or off. |
void |
startConfiguration()
Invoked before configuration is begun on this object |
String |
toString()
|
void |
updateValue(PCData data)
Determine what to based on addExistingUpdates(). |
| Methods inherited from class java.lang.Object |
|
| Methods inherited from interface com.solarmetric.kodo.runtime.datacache.DataCache |
pin, unpin |
| Field Detail |
protected static final org.apache.commons.logging.Log s_log
protected Map cache
| Constructor Detail |
public AbstractCacheImpl()
| Method Detail |
public Map getMap()
Returns the underlying Map 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.
protected abstract Map newMap()
Map for use as the underlying data
cache.protected void keyExpired(Object key)
protected abstract boolean addExistingUpdates()
true if updates to data already in the
cache (either in batchUpdate(java.util.Collection, java.util.Collection, java.util.Collection, java.util.Collection) or the updateValue(com.solarmetric.kodo.runtime.PCData)) should be put back into the cache.
public void batchUpdate(Collection additions,
Collection newUpdates,
Collection existingUpdates,
Collection deletes)
DataCachePerform a batch update of the cache. Add all PCData
objects in additions and in
newUpdates, make the appropriate modifications to
all PCDatas in existingUpdates, and delete all
OIDs in deletes.
All changes made to cached data must be cached via this method. It is this method that is responsible for performing any side-effects that should happen on meaningful cache changes.
Implementations should bear in mind that the
deletes collection may contain oids that are also
in the additions map. This is possible because it
is valid for a user to delete an object with a particular oid
and then add that object in the same batch.
batchUpdate in interface DataCachecom.solarmetric.kodo.runtime.datacache.DataCacheadditions - A collection of PCData objects. These
represent data that have been newly created,
and thus must be added to the cache.newUpdates - A collection of PCData objects. These
represent data that have been modified but
were not originally in the cache, and thus
must be added to the cache.existingUpdates - A collection of PCData objects. These
represent data that have been modified and
were originally loaded from the cache. It is
up to the cache implementation to decide if
these values must be re-enlisted in the cache.
Some caches may return live data from DataCache.get(java.lang.Object)
invocations, in which case these values need
not be re-enlisted.deletes - A collection of object IDs that have been deleted
and must therefore be dropped from the cache.public PCData get(Object key)
DataCacheDataCache.updateValue(com.solarmetric.kodo.runtime.PCData)
method should be used to re-cache any changed objects.get in interface DataCachecom.solarmetric.kodo.runtime.datacache.DataCachepublic PCData put(PCData data)
DataCacheDataCache.batchUpdate(java.util.Collection, java.util.Collection, java.util.Collection, java.util.Collection) method.put in interface DataCachecom.solarmetric.kodo.runtime.datacache.DataCachenull if
the key was not previously cached. See Map.put(java.lang.Object, java.lang.Object)
for more information.public void updateValue(PCData data)
addExistingUpdates().updateValue in interface DataCachepublic PCData remove(Object key)
DataCacheDataCache.batchUpdate(java.util.Collection, java.util.Collection, java.util.Collection, java.util.Collection) method.remove in interface DataCachecom.solarmetric.kodo.runtime.datacache.DataCachenull if
the key was not previously cached. See Map.remove(java.lang.Object)
for more information.public void removeAll(Collection keys)
public void clear()
DataCacheDataCache.batchUpdate(java.util.Collection, java.util.Collection, java.util.Collection, java.util.Collection) method.clear in interface DataCachepublic void close()
DataCacheclose in interface DataCachepublic boolean containsKey(Object key)
DataCachetrue if this cache contains data
corresponding to key; otherwise returns
false.containsKey in interface DataCachepublic void setName(String name)
DataCachesetName in interface DataCachepublic String getName()
DataCachegetName in interface DataCachepublic boolean isDecorator()
DataCachetrue if this cache is a decorator that
wraps another cache. Otherwise, returns false.isDecorator in interface DataCachepublic DataCache removeDecorator()
DataCachethis.removeDecorator in interface DataCachepublic DataCache removeDecorators()
DataCachethis. This is equivalent to repeatedly invoking
DataCache.removeDecorator() until the returned DataCache returns
false from DataCache.isDecorator().removeDecorators in interface DataCachepublic void addExpirationListener(com.solarmetric.util.Listener listen)
DataCacheaddExpirationListener in interface DataCachepublic void removeExpirationListener(com.solarmetric.util.Listener listen)
DataCacheremoveExpirationListener in interface DataCachepublic int getHitCount()
get(java.lang.Object) method. This number is cleared when cache statistics
recording is first enabled (when setRecordCacheStatistics(boolean) is invoked with true,
and recording was previously off) and when #clearCacheStatistics is invoked.public int getMissCount()
get(java.lang.Object) method. This number is cleared when cache
statistics recording is disabled (when setRecordCacheStatistics(boolean) is invoked with false).public void setRecordCacheStatistics(boolean record)
getCacheStatisticsString()) will be
logged when closing the cache.public boolean getRecordCacheStatistics()
true if cache statistics recording is
currently on; otherwise returns false.public String getCacheStatisticsString()
hits / (hits+misses)).public String toString()
toString in class Objectpublic void startConfiguration()
ConfigurablestartConfiguration in interface Configurablepublic void endConfiguration()
ConfigurableendConfiguration in interface Configurable
|
SolarMetric Kodo JDO 2.5.8 generated on January 11 2004 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||