jodd.cache
Class NoCache<K,V>

java.lang.Object
  extended by jodd.cache.NoCache<K,V>
All Implemented Interfaces:
Cache<K,V>

public class NoCache<K,V>
extends java.lang.Object
implements Cache<K,V>

Simple no-cache implementations of Cache for situation when cache needs to be quickly turned-off.


Constructor Summary
NoCache()
           
 
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 isEmpty()
          Returns true if cache is empty.
 boolean isFull()
          Returns true if max cache capacity has been reached only if cache is size limited.
 java.util.Iterator<V> iterator()
          Returns iterator over non-expired values.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NoCache

public NoCache()
Method Detail

getCacheSize

public int getCacheSize()
Description copied from interface: Cache
Returns cache size or 0 if there is no size limit.

Specified by:
getCacheSize in interface Cache<K,V>

getCacheTimeout

public long getCacheTimeout()
Description copied from interface: Cache
Returns default timeout or 0 if it is not set.

Specified by:
getCacheTimeout in interface Cache<K,V>

put

public void put(K key,
                V object)
Description copied from interface: Cache
Adds an object to the cache with default timeout.

Specified by:
put in interface Cache<K,V>
See Also:
Cache.put(Object, Object, long)

put

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

Specified by:
put in interface Cache<K,V>

get

public V get(K key)
Description copied from interface: Cache
Retrieves an object from the cache. Returns null if object is not longer in cache or if it is expired.

Specified by:
get in interface Cache<K,V>

iterator

public java.util.Iterator<V> iterator()
Description copied from interface: Cache
Returns iterator over non-expired values.

Specified by:
iterator in interface Cache<K,V>

prune

public int prune()
Description copied from interface: Cache
Prunes objects from cache and returns the number of removed objects. Used strategy depends on cache implementation.

Specified by:
prune in interface Cache<K,V>

isFull

public boolean isFull()
Description copied from interface: Cache
Returns true if max cache capacity has been reached only if cache is size limited.

Specified by:
isFull in interface Cache<K,V>

remove

public void remove(K key)
Description copied from interface: Cache
Removes an object from the cache.

Specified by:
remove in interface Cache<K,V>

clear

public void clear()
Description copied from interface: Cache
Clears current cache.

Specified by:
clear in interface Cache<K,V>

size

public int size()
Description copied from interface: Cache
Returns current cache size.

Specified by:
size in interface Cache<K,V>

isEmpty

public boolean isEmpty()
Description copied from interface: Cache
Returns true if cache is empty.

Specified by:
isEmpty in interface Cache<K,V>


Copyright © 2003-2012 Jodd Team