org.mmbase.cache
Class QueryResultCache
java.lang.Object
org.mmbase.cache.Cache<SearchQuery,List<MMObjectNode>>
org.mmbase.cache.QueryResultCache
- All Implemented Interfaces:
- Map<SearchQuery,List<MMObjectNode>>, CacheMBean, EventListener, NodeEventListener, RelationEventListener, SizeMeasurable
- Direct Known Subclasses:
- AggregatedResultCache, MultilevelCache, NodeListCache, RelatedNodesCache
public abstract class QueryResultCache
- extends Cache<SearchQuery,List<MMObjectNode>>
- implements NodeEventListener, RelationEventListener
This cache provides a base implementation to cache the result of
SearchQuery's. Such a cache links a SearchQuery object to a list of
MMObjectNodes. A cache entry is automaticly invalidated if arbitrary node of
one of the types present in the SearchQuery is changed (,created or deleted).
This mechanism is not very subtle but it is garanteed to be correct. It means
though that your cache can be considerably less effective for queries
containing node types from which often nodes are edited.
- Since:
- MMBase-1.7
- Version:
- $Id: QueryResultCache.java 37235 2009-07-23 20:01:34Z michiel $
- Author:
- Daniel Ockeloen, Michiel Meeuwissen, Ernst Bunders
- See Also:
SearchQuery- To Do:
- Perhaps we could put the 'typeCounter' stuff in a sub-class.
| Nested classes/interfaces inherited from interface java.util.Map |
Map.Entry<K,V> |
| Methods inherited from class org.mmbase.cache.Cache |
checkCachePolicy, contains, containsKey, containsValue, entrySet, equals, get, getByteSize, getByteSize, getCheapByteSize, getCount, getDefaultMaxEntrySize, getDescription, getHits, getImplementation, getLock, getMaxEntrySize, getMaxSize, getMisses, getName, getPuts, getRatio, getSize, getStats, hashCode, isActive, isEmpty, keySet, maxSize, putAll, putCache, reset, setActive, setImplementation, setMaxEntrySize, setMaxSize, size, values |
QueryResultCache
public QueryResultCache(int size)
addReleaseStrategies
public void addReleaseStrategies(List<ReleaseStrategy> strategies)
- Parameters:
strategies -
addReleaseStrategy
public void addReleaseStrategy(ReleaseStrategy releaseStrategy)
- This method lets you add a release strategy to the cache. It will in fact
be added to
ChainedReleaseStrategy, which
is the default base release strategy.
- Parameters:
releaseStrategy - A releaseStrategy to add.
getReleaseStrategy
public ChainedReleaseStrategy getReleaseStrategy()
- Returns:
- Returns the releaseStrategy.
put
public List<MMObjectNode> put(SearchQuery query,
List<MMObjectNode> queryResult)
- Puts a search result in this cache.
- Specified by:
put in interface Map<SearchQuery,List<MMObjectNode>>- Overrides:
put in class Cache<SearchQuery,List<MMObjectNode>>
remove
public List<MMObjectNode> remove(Object key)
- Removes an object from the cache. It alsos remove the watch from the
observers which are watching this entry.
- Specified by:
remove in interface Map<SearchQuery,List<MMObjectNode>>- Overrides:
remove in class Cache<SearchQuery,List<MMObjectNode>>
- Parameters:
key - A SearchQuery object.- See Also:
Map.remove(java.lang.Object)
getAvarageValueLength
public double getAvarageValueLength()
- Description copied from class:
Cache
- Returns the average 'length' of the values in the cache. Whatever that may mean. For a
QueryResultCache the length obviously is the length of the cached lists.
May return NaN if unknown or undetermined.
- Specified by:
getAvarageValueLength in interface CacheMBean- Overrides:
getAvarageValueLength in class Cache<SearchQuery,List<MMObjectNode>>
toString
public String toString()
- Overrides:
toString in class Cache<SearchQuery,List<MMObjectNode>>
notify
public void notify(RelationEvent event)
- Specified by:
notify in interface RelationEventListener
- See Also:
RelationEventListener.notify(org.mmbase.core.event.RelationEvent)
notify
public void notify(NodeEvent event)
- Specified by:
notify in interface NodeEventListener
- See Also:
NodeEventListener.notify(org.mmbase.core.event.NodeEvent)
nodeChanged
protected int nodeChanged(Event event)
throws IllegalArgumentException
- Throws:
IllegalArgumentException
clear
public void clear()
- Specified by:
clear in interface Map<SearchQuery,List<MMObjectNode>>- Specified by:
clear in interface CacheMBean- Overrides:
clear in class Cache<SearchQuery,List<MMObjectNode>>
- See Also:
Map.clear()
MMBase 2.0-SNAPSHOT - null