| java.lang.Object org.mmbase.cache.Cache
Cache | abstract public class Cache implements SizeMeasurable,Map<K, V>(Code) | | A base class for all Caches. Extend this class for other caches.
author: Michiel Meeuwissen version: $Id: Cache.java,v 1.49 2008/02/03 17:33:56 nklasens Exp $ |
Constructor Summary | |
public | Cache(int size) |
maxEntrySize | protected int maxEntrySize(Code) | | |
Cache | public Cache(int size)(Code) | | |
checkCachePolicy | protected boolean checkCachePolicy(Object key)(Code) | | Checks whether the key object should be cached.
This method returns false if either the current cache is inactive, or the object to cache
has a cache policy associated that prohibits caching of the object.
Parameters: key - the object to be cached true if the object can be cached since: MMBase-1.8 |
get | public V get(Object key)(Code) | | Like 'get' of Maps but considers if the cache is active or not, and the cache policy of the key.
|
getByteSize | public int getByteSize()(Code) | | |
getCheapByteSize | public int getCheapByteSize()(Code) | | Returns the sum of bytesizes of every key and value. This may count too much, because objects
(like Nodes) may occur in more then one value, but this is considerably cheaper then
Cache.getByteSize() , which has to keep a Collection of every counted object.
since: MMBase-1.8 |
getCount | public int getCount(K key)(Code) | | |
getDefaultMaxEntrySize | protected int getDefaultMaxEntrySize()(Code) | | This has to be overridden by Caches which support max entry size.
|
getDescription | public String getDescription()(Code) | | Gives a description for this cache type. This can be used in
cache overviews.
|
getHits | public long getHits()(Code) | | Returns the number of times an element was succesfully retrieved
from the table.
|
getMaxEntrySize | public int getMaxEntrySize()(Code) | | Return the maximum entry size for the cache in bytes. If the
cache-type supports it (default no), then no values bigger then
this will be stored in the cache.
|
getMisses | public long getMisses()(Code) | | Returns the number of times an element cpould not be retrieved
from the table.
|
getName | public String getName()(Code) | | Returns a name for this cache type. Default it is the class
name, but this normally will be overriden.
|
getPuts | public long getPuts()(Code) | | Returns the number of times an element was committed to the table.
|
getRatio | public double getRatio()(Code) | | Returns the ratio of hits and misses.
The higher the ratio, the more succesfull the table retrieval is.
A value of 1 means every attempt to retrieve data is succesfull,
while a value nearing 0 means most times the object requested it is
not available.
Generally a high ratio means the table can be shrunk, while a low ratio
means its size needs to be increased.
A double between 0 and 1 or NaN. |
getStats | public String getStats()(Code) | | Returns statistics on this table.
The information shown includes number of accesses, ratio of misses and hits,
current size, and number of puts.
|
isActive | final public boolean isActive()(Code) | | Wether this cache is active or not.
|
maxSize | public int maxSize()(Code) | | |
put | public V put(K key, V value)(Code) | | Like 'put' of LRUHashtable but considers if the cache is active or not.
|
setActive | public void setActive(boolean a)(Code) | | Sets this cache to active or passive.
TODO: Writing back to caches.xml if necessary (if this call was nog caused by change of caches.xml itself)
|
setMaxSize | public void setMaxSize(int size)(Code) | | |
|
|