|
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.QueryCacheImpl
Default query cache implementation.
Constructor Summary | |
QueryCacheImpl()
|
Method Summary | |
void |
classesChanged(Collection classes)
Invoked when objects of the types in the classes set have been changed. |
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. |
void |
endConfiguration()
Invoked upon completion of bean property configuration for this object. |
List |
get(QueryKey qk)
Return a list of OIDs for the given query key. |
CacheMap |
getCacheMap()
Returns the underlying CacheMap that this
QueryCacheImpl is using. |
int |
getCacheSize()
Returns the maximum number of unpinned objects to keep hard references to. |
QueryKeyExpirationListener |
getExpirationListener()
Returns this query cache's expiration listener. |
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 CacheMap |
newCacheMap()
Returns a new CacheMap for use as the underlying data
cache. |
void |
notifyChangedClasses(Collection classes)
Tells the cache that all the classes in the classes set have been changed. |
boolean |
pin(QueryKey qk)
Pin the value stored under qk into the
cache. |
List |
put(QueryKey qk,
List oids)
Set the list of OIDs for the given query key. |
void |
registerListener(ClassChangeListener ccl)
Register ccl with this cache. |
List |
remove(QueryKey qk)
Remove the value stored under the given query key. |
void |
removeListener(ClassChangeListener ccl)
Unregister ccl from the set of listeners managed
by this cache. |
void |
setCacheSize(int size)
Sets the maximum number of unpinned objects to keep hard references to. |
void |
setConfiguration(Configuration conf)
Invoked prior to setting bean properties. |
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. |
void |
startConfiguration()
Invoked before bean property configuration is begun on this object. |
boolean |
unpin(QueryKey qk)
Unpin the value stored under key into the cache. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public QueryCacheImpl()
Method Detail |
public CacheMap getCacheMap()
Returns the underlying CacheMap
that this
QueryCacheImpl
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. Additionally, this map may contain
expired data. Removal of timed-out data is done in a lazy
fashion, so the actual size of the map may be greater than the
number of non-expired query results in cache.
Methods that manipulate the cache map should synchronize on the map.
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 setKeepSoftReferences(boolean refs)
true
.public boolean getKeepSoftReferences()
protected CacheMap newCacheMap()
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
.public void notifyChangedClasses(Collection classes)
QueryCache
Tells the cache that all the classes in the
classes
set have been changed. This could mean
that items have been updated, deleted, or added. This limits
the QueryCache
to only be able to invalidate
cached queries -- because the cache is not notified of actual
changes, it cannot recompute query results.
After this method is invoked, all cached results that
correspond to queries that use one of the classes in
classes
will be dropped.
notifyChangedClasses
in interface QueryCache
kodo.datacache.QueryCache
classes
- a set of Class
objects that
correspond to instances that have changedpublic void registerListener(ClassChangeListener ccl)
QueryCache
ccl
with this cache.registerListener
in interface QueryCache
public void removeListener(ClassChangeListener ccl)
QueryCache
ccl
from the set of listeners managed
by this cache.removeListener
in interface QueryCache
public void classesChanged(Collection classes)
ClassChangeListener
Invoked when objects of the types in the
classes
set have been changed. This could mean
that items have been updated, deleted, or added.
classesChanged
in interface ClassChangeListener
kodo.datacache.ClassChangeListener
classes
- a set of Class
objects that
correspond to instances that have changedpublic List get(QueryKey qk)
QueryCache
Return a list of OIDs for the given query key. This is an unmodifiable list.
get
in interface QueryCache
kodo.datacache.QueryCache
public List put(QueryKey qk, List oids)
QueryCache
Set the list of OIDs for the given query key. A reference to the given list will be stored in the query cache, so the list should not be modified after invoking this method.
put
in interface QueryCache
kodo.datacache.QueryCache
null
if
the key was not previously cached. See Map.put(java.lang.Object, java.lang.Object)
for more information.public List remove(QueryKey qk)
QueryCache
Remove the value stored under the given query key.
This method is typically not invoked directly from outside
the QueryCache
class. Instead, the cache should
be updated by invoking QueryCache.notifyChangedClasses(java.util.Collection)
, which will
result in all queries that may be invalid being dropped.
remove
in interface QueryCache
kodo.datacache.QueryCache
null
if
the key was not previously cached. See Map.remove(java.lang.Object)
for more information.public void clear()
QueryCache
Remove all data from this cache.
clear
in interface QueryCache
public boolean pin(QueryKey qk)
QueryCache
qk
into the
cache. This method guarantees that qk
's value
will not be expired if the cache exceeds its capacity. It
causes this data to be ignored when determining whether or not
the cache is full, effectively increasing the total amount of
data stored in the cache. This method does not affect the
behavior of QueryCache.remove(kodo.datacache.QueryKey)
or QueryCache.notifyChangedClasses(java.util.Collection)
.pin
in interface QueryCache
kodo.datacache.QueryCache
true
if key
's value was
pinned into the cache; false
if the
key is not in the cache.public boolean unpin(QueryKey qk)
QueryCache
key
into the cache.
This method reverses a previous invocation of QueryCache.pin(kodo.datacache.QueryKey)
.
This method does not remove anything from the cache; it merely
makes key
's value a candidate for flushing from
the cache.unpin
in interface QueryCache
kodo.datacache.QueryCache
true
if key
's value was
unpinned from the cache; false
if the
key is not in the cache.public void close()
QueryCache
close
in interface QueryCache
public QueryKeyExpirationListener getExpirationListener()
QueryCache
getExpirationListener
in interface QueryCache
public void setConfiguration(Configuration conf)
Configurable
setConfiguration
in interface Configurable
public void startConfiguration()
Configurable
startConfiguration
in interface Configurable
public void endConfiguration()
Configurable
endConfiguration
in interface Configurable
|
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 |