Description |
|---|
|
LRU caching map is Least Recent Used Map , (see Wiki), meaning that a Key ,Value pair is stored in the cache, with a expireTime , but every time the Key is retrieved (get method) the expire time is extended.When the cache reaches is maxSize or a cleanup of the cache is performed (automatically by deamon thread dependent on the LRUCachingMapConfiguration),it is the keys that is least recent used (lowest expire time) that is discarded first. This library has extended configuration, so you have the ability to set how times a keys expired time can be extended. See more about the configuration abilities at Configuration. But if extendTime is set to zero, it will be behave as a normal cache.Additionally this library has ValueManager interface, which wraps how the Value is stored.This can be in Memory or in a Persistent storage like File , FileReference or Database .Persistent storage will give ability to restore the cache.The interface for this library is: public interface LRUCachingMap<K,V> { public Logger getLogger(); public int removeAll(); public int cleanup(); public boolean exists(K key) throws NullPointerException; public void extend(K key) throws NullPointerException; public void extend(K key,long extendTime) throws NullPointerException; public boolean isExpired(K key) throws NullPointerException; public V get(K key) throws NullPointerException; public V get(K... keys) throws NullPointerException; public LRUCachingMapConfiguration getConfiguration(); public Date getExpirationDateTime(K key) throws NullPointerException; public TimeSpan getExpirationTimeSpan(); public Iterator<K> getKeys(); public K getNextToExpire(); public Date getStoreDateTime(K key) throws NullPointerException; public ValueManager<K,V> getValueManager(); public V put(K key,V value) throws NullPointerException; public V remove(K key) throws NullPointerException; public void restoreCacheElement(K key, AbstractValueWrapper<K,V> valueWrapper,Date expireDateTime); public int reload(); public int size(); public boolean isPersisted(); public Date getLastCleanupDateTime(); } |