net.sf.extjwnl.util.cache
Interface Cache<K,V>

All Known Implementing Classes:
LRUCache

public interface Cache<K,V>

A Cache is a collection of values that are indexed by keys and that are stored for an unspecified amount of time (which the implementor of Cache may further specify).

Author:
John Didion , Aliaksandr Autayeu

Method Summary
 void clear()
          Remove all values stored in this cache.
 V get(K key)
          If key was used in a previous call to put, this call may return the value of that call.
 int getCapacity()
          Returns the maximum number of elements the cache can hold.
 int getSize()
          Returns the current size of the cache.
 V put(K key, V value)
          Store value in the cache, indexed by key.
 V remove(K key)
          Removes the object associated with key and returns that object.
 int setCapacity(int capacity)
          Set the maximum number of elements the cache can hold.
 Collection<V> values()
           
 

Method Detail

put

V put(K key,
      V value)
Store value in the cache, indexed by key. This operation makes it likely, although not certain, that a subsequent call to get with the same (equal) key will retrieve the same (==) value.

Multiple calls to put with the same key and value are idempotent. A set of calls to put with the same key but different values has only the affect of the last call (assuming there were no intervening calls to get).

Parameters:
key - key
value - value
Returns:
value

get

V get(K key)
If key was used in a previous call to put, this call may return the value of that call. Otherwise it returns null.

Parameters:
key - key
Returns:
value

remove

V remove(K key)
Removes the object associated with key and returns that object.

Parameters:
key - key
Returns:
removed object

getCapacity

int getCapacity()
Returns the maximum number of elements the cache can hold.

Returns:
the maximum number of elements the cache can hold

setCapacity

int setCapacity(int capacity)
Set the maximum number of elements the cache can hold.

Parameters:
capacity - capacity
Returns:
new capacity

getSize

int getSize()
Returns the current size of the cache.

Returns:
size

clear

void clear()
Remove all values stored in this cache. Subsequent calls to get will return null.


values

Collection<V> values()


Copyright © 2011. All Rights Reserved.