org.mmbase.cache
Class QueryResultCache

java.lang.Object
  extended byorg.mmbase.cache.Cache
      extended byorg.mmbase.cache.QueryResultCache
All Implemented Interfaces:
Map, SizeMeasurable
Direct Known Subclasses:
AggregatedResultCache, MultilevelCache, NodeListCache, RelatedNodesCache

public abstract class QueryResultCache
extends Cache

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 node are edited.

Since:
MMBase-1.7
Version:
$Id: QueryResultCache.java,v 1.34 2006/06/27 07:31:46 michiel Exp $
Author:
Daniel Ockeloen, Michiel Meeuwissen, Bunst Eunders
See Also:
SearchQuery

Nested Class Summary
 
Nested classes inherited from class java.util.Map
Map.Entry
 
Field Summary
 
Fields inherited from class org.mmbase.cache.Cache
maxEntrySize
 
Method Summary
 void addReleaseStrategies(List strategies)
           
 void addReleaseStrategy(ReleaseStrategy releaseStrategy)
          This method lets you add a release strategy to the cache.
 void clear()
           
 ChainedReleaseStrategy getReleaseStrategy()
           
 Iterator observerIterator()
           
 Object put(Object key, Object value)
          Like 'put' of LRUHashtable but considers if the cache is active or not.
 Object put(SearchQuery query, List queryResult)
          Puts a search result in this cache.
 Object remove(Object key)
          Removes an object from the cache.
 String toString()
           
 
Methods inherited from class org.mmbase.cache.Cache
checkCachePolicy, contains, containsKey, containsValue, entrySet, equals, get, getByteSize, getByteSize, getCache, getCaches, getCheapByteSize, getCount, getDefaultMaxEntrySize, getDescription, getHits, getMaxEntrySize, getMisses, getName, getPuts, getRatio, getStats, getTotalByteSize, hashCode, isActive, isEmpty, keySet, main, maxSize, putAll, putCache, putCache, setActive, setMaxSize, size, values
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

addReleaseStrategies

public void addReleaseStrategies(List 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.

observerIterator

public Iterator observerIterator()
Returns:
an iterator of all observer instances

put

public Object put(Object key,
                  Object value)
Description copied from class: Cache
Like 'put' of LRUHashtable but considers if the cache is active or not.

Specified by:
put in interface Map
Overrides:
put in class Cache
Throws:
ClassCastException - if key not a SearchQuery or value not a List.

put

public Object put(SearchQuery query,
                  List queryResult)
Puts a search result in this cache.


remove

public Object 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
Overrides:
remove in class Cache
Parameters:
key - A SearchQuery object.
See Also:
Map.remove(java.lang.Object)

toString

public String toString()
Overrides:
toString in class Cache

clear

public void clear()
Specified by:
clear in interface Map
Overrides:
clear in class Cache
See Also:
Map.clear()


MMBase build 1.8.1.20060716