info.aduna.gee.publication.servlets.util
Class ExpiringCache

java.lang.Object
  extended by info.aduna.gee.publication.servlets.util.ExpiringCache

public class ExpiringCache
extends Object

A cache of key-value pairs in which a "put" value is valid only for maximum time-to-live (ttl). There is no "containsKey" method in order to avoid timing problems. Just "get" and check.


Nested Class Summary
 class ExpiringCache.TimedValue
          To store the original "value" plus its "time" in a Hashtable we have to combine these two.
 
Field Summary
protected  Vector _sequence
           
protected  int _size
           
protected  Hashtable _timedValues
           
protected  int _ttl
           
 
Constructor Summary
ExpiringCache(int size, int ttl)
           
 
Method Summary
 Object get(Object key)
           
 void put(Object key, Object value)
           
 void remove(Object key)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_sequence

protected Vector _sequence

_timedValues

protected Hashtable _timedValues

_size

protected int _size

_ttl

protected int _ttl
Constructor Detail

ExpiringCache

public ExpiringCache(int size,
                     int ttl)
Parameters:
size - The maximum amount of objects in the cache or infinit if less than or equal to 0.
ttl - The maximum time to live of objects in the cache or infinit if less than or equal to 0.
Method Detail

put

public void put(Object key,
                Object value)

get

public Object get(Object key)

remove

public void remove(Object key)


Copyright © 1997-2008 Aduna. All Rights Reserved.