com.scooterframework.cache
Class NamedCurrentThreadCache

java.lang.Object
  extended by com.scooterframework.cache.NamedCurrentThreadCache
All Implemented Interfaces:
Cache

public class NamedCurrentThreadCache
extends java.lang.Object
implements Cache

NamedCurrentThreadCache provides a named cache for current request thread.

The scope of a NamedCurrentThreadCache is just the current request. If the current thread completes, all objects cached in it will be removed.


Constructor Summary
NamedCurrentThreadCache(java.lang.String name)
           
 
Method Summary
 void clear()
          Removes all key/value pairs from cache.
 java.lang.Object get(java.lang.Object key)
          Returns object from cache based on key.
 java.lang.Object getDelegateCache()
          Returns the underlying cache.
 java.util.Collection<java.lang.Object> getKeys()
          Returns keys in the cache
 java.lang.String getName()
          Returns the cache name.
 java.util.Properties getStatistics()
          Returns the Cache statistics.
 boolean put(java.lang.Object key, java.lang.Object value)
          Stores object into cache based on key.
 boolean remove(java.lang.Object key)
          Removes the mapping for this key from the cache if present.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NamedCurrentThreadCache

public NamedCurrentThreadCache(java.lang.String name)
Method Detail

getDelegateCache

public java.lang.Object getDelegateCache()
Returns the underlying cache.

Specified by:
getDelegateCache in interface Cache
Returns:
the cache instance from vendor

getName

public java.lang.String getName()
Returns the cache name.

Specified by:
getName in interface Cache
Returns:
name of the cache

getKeys

public java.util.Collection<java.lang.Object> getKeys()
Returns keys in the cache

Specified by:
getKeys in interface Cache
Returns:
a collection of all keys

get

public java.lang.Object get(java.lang.Object key)
Returns object from cache based on key.

Specified by:
get in interface Cache
Returns:
the value to which this cache maps the specified key, or null if the cache contains no mapping for this key.

put

public boolean put(java.lang.Object key,
                   java.lang.Object value)
Stores object into cache based on key.

Specified by:
put in interface Cache
Returns:
true if successful

remove

public boolean remove(java.lang.Object key)
Removes the mapping for this key from the cache if present.

Specified by:
remove in interface Cache
Returns:
true if successful

clear

public void clear()
Removes all key/value pairs from cache.

Specified by:
clear in interface Cache

getStatistics

public java.util.Properties getStatistics()
Returns the Cache statistics.

Specified by:
getStatistics in interface Cache