jodd.cache
Interface Cache<K,V>

All Known Implementing Classes:
AbstractCacheMap, FIFOCache, LFUCache, LRUCache, NoCache, TimedCache

public interface Cache<K,V>

Cache interface.


Method Summary
 void clear()
          Clears current cache.
 V get(K key)
          Retrieves an object from the cache.
 int getCacheSize()
          Returns cache size or 0 if there is no size limit.
 long getCacheTimeout()
          Returns default timeout or 0 if it is not set.
 boolean isFull()
          Returns true if max cache capacity has been reached only if cache is size limited.
 int prune()
          Prunes objects from cache and returns the number of removed objects.
 void put(K key, V object)
          Adds an object to the cache with default timeout.
 void put(K key, V object, long timeout)
          Adds an object to the cache with specified timeout after which it becomes expired.
 void remove(K key)
          Removes an object from the cache.
 int size()
          Returns current cache size.
 

Method Detail

getCacheSize

int getCacheSize()
Returns cache size or 0 if there is no size limit.


getCacheTimeout

long getCacheTimeout()
Returns default timeout or 0 if it is not set.


put

void put(K key,
         V object)
Adds an object to the cache with default timeout.

See Also:
put(Object, Object, long)

put

void put(K key,
         V object,
         long timeout)
Adds an object to the cache with specified timeout after which it becomes expired. If cache is full, prune is invoked to make room for new object.


get

V get(K key)
Retrieves an object from the cache. Returns null if object is not longer in cache or if it is expired.


prune

int prune()
Prunes objects from cache and returns the number of removed objects. Which strategy is used depends on cache implementation.


isFull

boolean isFull()
Returns true if max cache capacity has been reached only if cache is size limited.


remove

void remove(K key)
Removes an object from the cache.


clear

void clear()
Clears current cache.


size

int size()
Returns current cache size.



Copyright ©2008 Jodd Team