Openfire 3.6.1 Javadoc

org.jivesoftware.util.cache
Class CacheWrapper<K,V>

java.lang.Object
  extended by org.jivesoftware.util.cache.CacheWrapper<K,V>
All Implemented Interfaces:
Map<K,V>, Cache<K,V>

public class CacheWrapper<K,V>
extends Object
implements Cache<K,V>

Acts as a proxy for a Cache implementation. The Cache implementation can be switched on the fly, which enables users to hold a reference to a CacheWrapper object, but for the underlying Cache implementation to switch from clustered to local, etc.


Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
CacheWrapper(Cache<K,V> cache)
           
 
Method Summary
 void clear()
           
 boolean containsKey(Object key)
           
 boolean containsValue(Object value)
           
 Set<Map.Entry<K,V>> entrySet()
           
 V get(Object key)
           
 long getCacheHits()
          Returns the number of cache hits.
 long getCacheMisses()
          Returns the number of cache misses.
 int getCacheSize()
          Returns the size of the cache contents in bytes.
 long getMaxCacheSize()
          Returns the maximum size of the cache in bytes.
 long getMaxLifetime()
          Returns the maximum number of milliseconds that any object can live in cache.
 String getName()
          Returns the name of the cache.
 Cache<K,V> getWrappedCache()
           
 boolean isEmpty()
           
 Set<K> keySet()
           
 V put(K key, V value)
           
 void putAll(Map<? extends K,? extends V> t)
           
 V remove(Object key)
           
 void setMaxCacheSize(int maxSize)
          Sets the maximum size of the cache in bytes.
 void setMaxLifetime(long maxLifetime)
          Sets the maximum number of milliseconds that any object can live in cache.
 void setName(String name)
          Sets the name of the cache
 void setWrappedCache(Cache<K,V> cache)
           
 int size()
           
 Collection<V> values()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

CacheWrapper

public CacheWrapper(Cache<K,V> cache)
Method Detail

getWrappedCache

public Cache<K,V> getWrappedCache()

setWrappedCache

public void setWrappedCache(Cache<K,V> cache)

getName

public String getName()
Description copied from interface: Cache
Returns the name of the cache.

Specified by:
getName in interface Cache<K,V>
Returns:
the name of the cache.

setName

public void setName(String name)
Description copied from interface: Cache
Sets the name of the cache

Specified by:
setName in interface Cache<K,V>
Parameters:
name - the name of the cache

getMaxCacheSize

public long getMaxCacheSize()
Description copied from interface: Cache
Returns the maximum size of the cache in bytes. If the cache grows larger than the max size, the least frequently used items will be removed. If the max cache size is set to -1, there is no size limit.

Specified by:
getMaxCacheSize in interface Cache<K,V>
Returns:
the maximum size of the cache in bytes.

setMaxCacheSize

public void setMaxCacheSize(int maxSize)
Description copied from interface: Cache
Sets the maximum size of the cache in bytes. If the cache grows larger than the max size, the least frequently used items will be removed. If the max cache size is set to -1, there is no size limit.

Specified by:
setMaxCacheSize in interface Cache<K,V>
Parameters:
maxSize - the maximum size of the cache in bytes.

getMaxLifetime

public long getMaxLifetime()
Description copied from interface: Cache
Returns the maximum number of milliseconds that any object can live in cache. Once the specified number of milliseconds passes, the object will be automatically expried from cache. If the max lifetime is set to -1, then objects never expire.

Specified by:
getMaxLifetime in interface Cache<K,V>
Returns:
the maximum number of milliseconds before objects are expired.

setMaxLifetime

public void setMaxLifetime(long maxLifetime)
Description copied from interface: Cache
Sets the maximum number of milliseconds that any object can live in cache. Once the specified number of milliseconds passes, the object will be automatically expried from cache. If the max lifetime is set to -1, then objects never expire.

Specified by:
setMaxLifetime in interface Cache<K,V>
Parameters:
maxLifetime - the maximum number of milliseconds before objects are expired.

getCacheSize

public int getCacheSize()
Description copied from interface: Cache
Returns the size of the cache contents in bytes. This value is only a rough approximation, so cache users should expect that actual VM memory used by the cache could be significantly higher than the value reported by this method.

Specified by:
getCacheSize in interface Cache<K,V>
Returns:
the size of the cache contents in bytes.

getCacheHits

public long getCacheHits()
Description copied from interface: Cache
Returns the number of cache hits. A cache hit occurs every time the get method is called and the cache contains the requested object.

Keeping track of cache hits and misses lets one measure how efficient the cache is; the higher the percentage of hits, the more efficient.

Specified by:
getCacheHits in interface Cache<K,V>
Returns:
the number of cache hits.

getCacheMisses

public long getCacheMisses()
Description copied from interface: Cache
Returns the number of cache misses. A cache miss occurs every time the get method is called and the cache does not contain the requested object.

Keeping track of cache hits and misses lets one measure how efficient the cache is; the higher the percentage of hits, the more efficient.

Specified by:
getCacheMisses in interface Cache<K,V>
Returns:
the number of cache hits.

size

public int size()
Specified by:
size in interface Map<K,V>

clear

public void clear()
Specified by:
clear in interface Map<K,V>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Map<K,V>

containsKey

public boolean containsKey(Object key)
Specified by:
containsKey in interface Map<K,V>

containsValue

public boolean containsValue(Object value)
Specified by:
containsValue in interface Map<K,V>

values

public Collection<V> values()
Specified by:
values in interface Map<K,V>

putAll

public void putAll(Map<? extends K,? extends V> t)
Specified by:
putAll in interface Map<K,V>

entrySet

public Set<Map.Entry<K,V>> entrySet()
Specified by:
entrySet in interface Map<K,V>

keySet

public Set<K> keySet()
Specified by:
keySet in interface Map<K,V>

get

public V get(Object key)
Specified by:
get in interface Map<K,V>

remove

public V remove(Object key)
Specified by:
remove in interface Map<K,V>

put

public V put(K key,
             V value)
Specified by:
put in interface Map<K,V>

Openfire 3.6.1 Javadoc

Copyright © 2003-2008 Jive Software.