JSecurity

org.jsecurity.cache
Class HashtableCache

java.lang.Object
  extended by org.jsecurity.cache.HashtableCache
All Implemented Interfaces:
Cache

public class HashtableCache
extends Object
implements Cache

An implementation of the JSecurity Cache interface that uses a Hashtable to store cached objects. This implementation is only suitable for development/testing use. A more robust caching solution should be used for production systems such as the EhCacheManager

Since:
0.2
Author:
Jeremy Haile, Les Hazlewood

Constructor Summary
HashtableCache(String name)
          Creates a new cache with the given name.
 
Method Summary
 void clear()
          Clear all entries from the cache.
 Object get(Object key)
          Returns the Cached value stored under the specified key or null if there is no Cache entry for that key.
 Set keys()
          Returns a view of all the keys for entries contained in this cache.
 void put(Object key, Object value)
          Adds a Cache entry.
 Object read(Object key)
           
 void remove(Object key)
          Remove the cache entry corresponding to the specified key.
 int size()
          Returns the number of entries in the cache.
 String toString()
           
 Set values()
          Returns a view of all of the values contained in this cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HashtableCache

public HashtableCache(String name)
Creates a new cache with the given name.

Parameters:
name - the name of this cache.
Method Detail

read

public Object read(Object key)
            throws CacheException
Throws:
CacheException

get

public Object get(Object key)
           throws CacheException
Description copied from interface: Cache
Returns the Cached value stored under the specified key or null if there is no Cache entry for that key.

Specified by:
get in interface Cache
Parameters:
key - the key that the value was previous added with
Returns:
the cached object or null if there is no Cache entry for the specified key
Throws:
CacheException - if there is a problem accessing the underlying cache system

put

public void put(Object key,
                Object value)
         throws CacheException
Description copied from interface: Cache
Adds a Cache entry.

Specified by:
put in interface Cache
Parameters:
key - the key used to identify the object being stored.
value - the value to be stored in the cache.
Throws:
CacheException - if there is a problem accessing the underlying cache system

remove

public void remove(Object key)
            throws CacheException
Description copied from interface: Cache
Remove the cache entry corresponding to the specified key.

Specified by:
remove in interface Cache
Parameters:
key - the key of the entry to be removed.
Throws:
CacheException - if there is a problem accessing the underlying cache system

clear

public void clear()
           throws CacheException
Description copied from interface: Cache
Clear all entries from the cache.

Specified by:
clear in interface Cache
Throws:
CacheException - if there is a problem accessing the underlying cache system

size

public int size()
Description copied from interface: Cache
Returns the number of entries in the cache.

Specified by:
size in interface Cache
Returns:
the number of entries in the cache.

keys

public Set keys()
Description copied from interface: Cache
Returns a view of all the keys for entries contained in this cache.

Specified by:
keys in interface Cache
Returns:
a view of all the keys for entries contained in this cache.

values

public Set values()
Description copied from interface: Cache
Returns a view of all of the values contained in this cache.

Specified by:
values in interface Cache
Returns:
a view of all of the values contained in this cache.

toString

public String toString()
Overrides:
toString in class Object

JSecurity

Copyright © 2004-2008 JSecurity.