|
SolarMetric Kodo JDO 3.0.3 generated on February 20 2004 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--kodo.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 JDOConfiguration |
conf
The configuration set by the system. |
protected org.apache.commons.logging.Log |
log
The log to use. |
Fields inherited from interface kodo.datacache.DataCache |
DEFAULT_NAME |
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(kodo.runtime.PCData) ) should be put back into the cache. |
boolean |
addListener(WatchableListener listener)
Add a listener. |
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 |
clearListeners()
Clear all listeners. |
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 oid ; otherwise returns
false . |
void |
endConfiguration()
Invoked upon completion of bean property configuration for this object. |
PCData |
get(Object key)
Return the cached object for the given oid. |
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 . |
Collection |
getStatistics()
Get statistics exported by this object. |
protected void |
keyRemoved(Object key,
boolean expired)
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 instance. |
void |
registerListener(ExpirationListener listen)
Add a new expiration event listener to this cache. |
PCData |
remove(Object key)
Remove the value stored under the given oid. |
void |
removeAll(Collection keys)
|
boolean |
removeListener(ExpirationListener listen)
Remove an expiration event listener from this cache. |
boolean |
removeListener(WatchableListener listener)
Remove a listener. |
void |
setConfiguration(Configuration config)
Invoked prior to setting bean properties. |
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 bean property 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 |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface kodo.datacache.DataCache |
pin, unpin |
Field Detail |
protected Map cache
protected JDOConfiguration conf
protected org.apache.commons.logging.Log log
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 keyRemoved(Object key, boolean expired)
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(kodo.runtime.PCData)
) should be put back into the cache.public void batchUpdate(Collection additions, Collection newUpdates, Collection existingUpdates, Collection deletes)
DataCache
Perform 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 DataCache
kodo.datacache.DataCache
additions
- 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)
DataCache
DataCache.updateValue(kodo.runtime.PCData)
method should be used to re-cache any changed objects.get
in interface DataCache
kodo.datacache.DataCache
public PCData put(PCData data)
DataCache
DataCache.batchUpdate(java.util.Collection, java.util.Collection, java.util.Collection, java.util.Collection)
method.put
in interface DataCache
kodo.datacache.DataCache
null
if
the value 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 DataCache
public PCData remove(Object key)
DataCache
DataCache.batchUpdate(java.util.Collection, java.util.Collection, java.util.Collection, java.util.Collection)
method.remove
in interface DataCache
kodo.datacache.DataCache
null
if
the oid was not previously cached. See Map.remove(java.lang.Object)
for more information.public void removeAll(Collection keys)
public void clear()
DataCache
DataCache.batchUpdate(java.util.Collection, java.util.Collection, java.util.Collection, java.util.Collection)
method.clear
in interface DataCache
public void close()
DataCache
close
in interface DataCache
public boolean containsKey(Object key)
DataCache
true
if this cache contains data
corresponding to oid
; otherwise returns
false
.containsKey
in interface DataCache
public void setName(String name)
DataCache
setName
in interface DataCache
public String getName()
DataCache
getName
in interface DataCache
public void registerListener(ExpirationListener listen)
DataCache
registerListener
in interface DataCache
public boolean removeListener(ExpirationListener listen)
DataCache
removeListener
in interface DataCache
public 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 Object
public void setConfiguration(Configuration config)
Configurable
setConfiguration
in interface Configurable
public void startConfiguration()
Configurable
startConfiguration
in interface Configurable
public void endConfiguration()
Configurable
endConfiguration
in interface Configurable
public Collection getStatistics()
getStatistics
in interface Watchable
public boolean addListener(WatchableListener listener)
Watchable
addListener
in interface Watchable
public boolean removeListener(WatchableListener listener)
Watchable
removeListener
in interface Watchable
public void clearListeners()
Watchable
clearListeners
in interface Watchable
|
SolarMetric Kodo JDO 3.0.3 generated on February 20 2004 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |