de.bea.domingo.cache
Interface Cache

All Known Implementing Classes:
AbstractBaseCache, SimpleCache, WeakCache

public interface Cache

Cache Interface.

Author:
Kurt Riede

Method Summary
 void clear()
          Removes all mappings from this map (optional operation).
 boolean containsKey(java.lang.Object key)
          Checks if a given key exists in the cache.
 java.lang.Object get(java.lang.Object key)
          Returns an object with a given key from the cache.
 java.util.Set keySet()
          Returns a set view of the keys contained in this cache.
 void put(java.lang.Object key, java.lang.Object value)
          Puts an object with a key into the cache.
 java.lang.Object remove(java.lang.Object key)
          Removes the mapping for this key from this cache if present (optional operation).
 int size()
          Returns the number of elements in this cache (its cardinality).
 java.util.Collection values()
          Returns a collection view of the values contained in this cache.
 

Method Detail

get

java.lang.Object get(java.lang.Object key)
Returns an object with a given key from the cache.

Parameters:
key - the key
Returns:
object with given key

put

void put(java.lang.Object key,
         java.lang.Object value)
Puts an object with a key into the cache.

Parameters:
key - the key
value - the object

containsKey

boolean containsKey(java.lang.Object key)
Checks if a given key exists in the cache.

Parameters:
key - the key
Returns:
true if the given key exists in the cache, else false

size

int size()
Returns the number of elements in this cache (its cardinality). If this set contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Returns:
the number of elements in this set (its cardinality).

remove

java.lang.Object remove(java.lang.Object key)
Removes the mapping for this key from this cache if present (optional operation).

This implementation iterates over entrySet() searching for an entry with the specified key. If such an entry is found, its value is obtained with its getValue operation, the entry is removed from the Collection (and the backing cache) with the iterator's remove operation, and the saved value is returned. If the iteration terminates without finding such an entry, null is returned. Note that this implementation requires linear time in the size of the cache; many implementations will override this method.

Parameters:
key - key whose mapping is to be removed from the cache.
Returns:
previous value associated with specified key, or null if there was no entry for key. (A null return can also indicate that the cache previously associated null with the specified key, if the implementation supports null values.)

clear

void clear()
Removes all mappings from this map (optional operation).


keySet

java.util.Set keySet()
Returns a set view of the keys contained in this cache. The set is backed by the cache, so changes to the cache are reflected in the set, and vice-versa. The set supports element removal, which removes the corresponding mapping from this cache, via the Iterator.remove, Set.remove, removeAll, retainAll, and clear operations. It does not support the add or addAll operations.

Returns:
a set view of the keys contained in this cache.

values

java.util.Collection values()
Returns a collection view of the values contained in this cache. The collection is backed by the cache, so changes to the cache are reflected in the collection, and vice-versa. The collection supports element removal, which removes the corresponding mapping from this cache, via the Iterator.remove, Collection.remove, removeAll, retainAll, and clear operations. It does not support the add or addAll operations.

Returns:
a collection view of the values contained in this cache.


Domingo Java-API