org.mmbase.cache.oscache
Class OSCacheImplementation<K,V>

java.lang.Object
  extended by org.mmbase.cache.oscache.OSCacheImplementation<K,V>
All Implemented Interfaces:
Map<K,V>, CacheImplementationInterface<K,V>

public class OSCacheImplementation<K,V>
extends Object
implements CacheImplementationInterface<K,V>

Implementation of the MMBase 'CacheImplementationInterface' interface, which delegates all calls to an OSCache implementation. This implementation accepts the following configuration properties:

To use this implementation, you can use a construction like this in your 'caches.xml' configuration file:
 <cache name="NodeListCache">
   <status>active</status>
   <size>3</size>
   <implementation>
     <class>org.mmbase.cache.oscache.OSCacheImplementation</class>
     <param name="path">/tmp</param>
   </implementation>
 </cache>
 

Author:
Johannes Verelst <johannes.verelst@eo.nl>

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
OSCacheImplementation()
           
 
Method Summary
 void clear()
          Wrapper around the clear() method of the cache implementation.
 void config(Map<String,String> config)
          This method is called by MMBase to configure the cache using the given map of configuration parameters.
 boolean containsKey(Object key)
          Wrapper around the containsKey() method of the cache implementation.
 boolean containsValue(Object value)
          Wrapper around the containsValue() method of the cache implementation.
 Set<Map.Entry<K,V>> entrySet()
          Wrapper around the entrySet() method of the cache implementation.
 boolean equals(Object o)
          Wrapper around the equals() method of the cache implementation.
 V get(Object key)
          Wrapper around the get() method of the cache implementation.
 int getByteSize()
           
 int getByteSize(SizeOf sizeof)
           
 int getCount(K key)
          Wrapper around the getCount() method of the cache implementation.
 Object getLock()
          The cache implementation must be somehow thread-safe.
 int hashCode()
          Wrapper around the hashCode() method of the cache implementation.
 boolean isEmpty()
          Wrapper around the isEmpty() method of the cache implementation.
 Set<K> keySet()
          Wrapper around the keySet() method of the cache implementation.
 int maxSize()
          Wrapper around the getMaxEntries() method of the cache implementation.
 V put(K key, V value)
          Wrapper around the put() method of the cache implementation.
 void putAll(Map t)
          Wrapper around the putAll() method of the cache implementation.
 V remove(Object key)
          Wrapper around the remove() method of the cache implementation.
 void setMaxSize(int size)
          Wrapper around the setMaxEntries() method of the cache implementation.
 int size()
          Wrapper around the size() method of the cache implementation.
 Collection<V> values()
          Wrapper around the values() method of the cache implementation.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OSCacheImplementation

public OSCacheImplementation()
Method Detail

config

public void config(Map<String,String> config)
This method is called by MMBase to configure the cache using the given map of configuration parameters.

Specified by:
config in interface CacheImplementationInterface<K,V>

setMaxSize

public void setMaxSize(int size)
Wrapper around the setMaxEntries() method of the cache implementation.

Specified by:
setMaxSize in interface CacheImplementationInterface<K,V>

maxSize

public int maxSize()
Wrapper around the getMaxEntries() method of the cache implementation.

Specified by:
maxSize in interface CacheImplementationInterface<K,V>

getCount

public int getCount(K key)
Wrapper around the getCount() method of the cache implementation. (not implemented)

Specified by:
getCount in interface CacheImplementationInterface<K,V>

clear

public void clear()
Wrapper around the clear() method of the cache implementation.

Specified by:
clear in interface Map<K,V>

containsKey

public boolean containsKey(Object key)
Wrapper around the containsKey() method of the cache implementation.

Specified by:
containsKey in interface Map<K,V>

containsValue

public boolean containsValue(Object value)
Wrapper around the containsValue() method of the cache implementation.

Specified by:
containsValue in interface Map<K,V>

entrySet

public Set<Map.Entry<K,V>> entrySet()
Wrapper around the entrySet() method of the cache implementation.

Specified by:
entrySet in interface Map<K,V>

equals

public boolean equals(Object o)
Wrapper around the equals() method of the cache implementation.

Specified by:
equals in interface Map<K,V>
Overrides:
equals in class Object

get

public V get(Object key)
Wrapper around the get() method of the cache implementation.

Specified by:
get in interface Map<K,V>

hashCode

public int hashCode()
Wrapper around the hashCode() method of the cache implementation.

Specified by:
hashCode in interface Map<K,V>
Overrides:
hashCode in class Object

isEmpty

public boolean isEmpty()
Wrapper around the isEmpty() method of the cache implementation.

Specified by:
isEmpty in interface Map<K,V>

keySet

public Set<K> keySet()
Wrapper around the keySet() method of the cache implementation.

Specified by:
keySet in interface Map<K,V>

put

public V put(K key,
             V value)
Wrapper around the put() method of the cache implementation.

Specified by:
put in interface Map<K,V>

putAll

public void putAll(Map t)
Wrapper around the putAll() method of the cache implementation.

Specified by:
putAll in interface Map<K,V>

remove

public V remove(Object key)
Wrapper around the remove() method of the cache implementation.

Specified by:
remove in interface Map<K,V>

size

public int size()
Wrapper around the size() method of the cache implementation.

Specified by:
size in interface Map<K,V>

values

public Collection<V> values()
Wrapper around the values() method of the cache implementation.

Specified by:
values in interface Map<K,V>

getByteSize

public int getByteSize()
See Also:
SizeMeasurable.getByteSize()

getByteSize

public int getByteSize(SizeOf sizeof)
See Also:
SizeMeasurable.getByteSize(org.mmbase.util.SizeOf)

getLock

public Object getLock()
Description copied from interface: CacheImplementationInterface
The cache implementation must be somehow thread-safe. This method should return the object on which to synchronize, e.g. when looping over entrySet.

Specified by:
getLock in interface CacheImplementationInterface<K,V>
To Do:
This will also be used to lock 'get' iteration operations in QueryResultCache, but that is not actually needed for this implementation. You cannot synchronize on null though, in java.


MMBase 2.0-SNAPSHOT - null