org.castor.cache.simple
Class TimeLimited<K,V>

java.lang.Object
  extended by org.castor.cache.AbstractBaseCache<K,V>
      extended by org.castor.cache.simple.TimeLimited<K,V>
Type Parameters:
K - the type of keys maintained by this cache
V - the type of cached values
All Implemented Interfaces:
Map<K,V>, Cache<K,V>

public class TimeLimited<K,V>
extends AbstractBaseCache<K,V>

TimeLimited is a time limted first-in-first-out Map. Every object being put in the Map will live until the timeout expired.

The expiration time is passed to the cache at initialization by the individual cache property ttl which defines the timeout of every object in the cache in seconds. If not specified a timeout of 30 seconds will be used.

Version:
$Revision: 9041 $ $Date: 2011-08-16 11:51:17 +0200 (Di, 16 Aug 2011) $
Author:
Thomas Yip, Stein M. Hugubakken, Werner Guttmann, Ralf Joachim

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
static int DEFAULT_TTL
          Default ttl of cache.
static String PARAM_TTL
          Mapped initialization parameter ttl.
static String TYPE
          The type of the cache.
 
Fields inherited from interface org.castor.cache.Cache
DEFAULT_DEBUG, DEFAULT_NAME, DEFAULT_TYPE, PARAM_DEBUG, PARAM_NAME, PARAM_TYPE
 
Constructor Summary
TimeLimited()
           
 
Method Summary
 void clear()
          
 boolean containsKey(Object key)
          
 boolean containsValue(Object value)
          
 Set<Map.Entry<K,V>> entrySet()
          
 V get(Object key)
          
 int getTTL()
          Get real ttl of this cache.
 String getType()
          Indicates the type of this cache.
 void initialize(Properties params)
          Lyfe-cycle method to allow custom initialization of cache implementations.
 boolean isEmpty()
          
 Set<K> keySet()
          
 V put(K key, V value)
          
 void putAll(Map<? extends K,? extends V> map)
          
 V remove(Object key)
          
 int size()
          
 Collection<V> values()
          
 
Methods inherited from class org.castor.cache.AbstractBaseCache
close, expire, expireAll, getName
 
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
 

Field Detail

TYPE

public static final String TYPE
The type of the cache.

See Also:
Constant Field Values

PARAM_TTL

public static final String PARAM_TTL
Mapped initialization parameter ttl.

See Also:
Constant Field Values

DEFAULT_TTL

public static final int DEFAULT_TTL
Default ttl of cache.

See Also:
Constant Field Values
Constructor Detail

TimeLimited

public TimeLimited()
Method Detail

initialize

public final void initialize(Properties params)
                      throws CacheAcquireException
Lyfe-cycle method to allow custom initialization of cache implementations.

Specified by:
initialize in interface Cache<K,V>
Overrides:
initialize in class AbstractBaseCache<K,V>
Parameters:
params - Parameters to initialize the cache (e.g. name, capacity).
Throws:
CacheAcquireException - If cache can not be initialized.

getType

public final String getType()
Indicates the type of this cache.

Returns:
The cache type.

getTTL

public final int getTTL()
Get real ttl of this cache.

Returns:
Real ttl of this cache.

size

public final int size()


isEmpty

public final boolean isEmpty()


containsKey

public final boolean containsKey(Object key)


containsValue

public final boolean containsValue(Object value)


get

public final V get(Object key)


put

public final V put(K key,
                   V value)


remove

public V remove(Object key)


putAll

public final void putAll(Map<? extends K,? extends V> map)


clear

public final void clear()


keySet

public final Set<K> keySet()


values

public final Collection<V> values()


entrySet

public final Set<Map.Entry<K,V>> entrySet()



Copyright © 2012. All Rights Reserved.