com.ibm.portal.cache
Interface Cache<K,V>

All Superinterfaces:
Identifiable
All Known Subinterfaces:
DependencyCache<K,V>

public interface Cache<K,V>
extends Identifiable

The CacheFactory can return caches with different underlying implementations, but all of them implement this interface. This interface defines the basic operations available on a cache. Note that this is a subset of the Map interface - for example, there's no way to iterate over all the keys in a Cache.

Note that there is no explicit garbage-collection method for a cache. Caches may perform garbage collection on put or get method calls, or they may use some background garbage collection scheme - this is entirely up to the underlying cache implementation.


Method Summary
 void clear()
          Clear the cache.
 V get(java.lang.Object key)
          Get an entry in the cache.
 void invalidate(java.lang.Object key)
          Invalidate a cache key.
 void put(K key, V value)
          Place an entry in the cache.
 
Methods inherited from interface com.ibm.portal.Identifiable
getObjectID
 

Method Detail

get

V get(java.lang.Object key)
Get an entry in the cache.

Parameters:
key - - the cache key

put

void put(K key,
         V value)
Place an entry in the cache. Note that there is no guarantee that the object will actually end up in the cache. The underlying cache implementation can choose not to actually store this key-value pair based on whatever arbitrary conditions it chooses.

If there is already an object in the cache under this key, that object will be replaced with this value. !Attention! this does not imply an invalidate() call on the key!

Parameters:
key - - the cache key, used to locate the entry on subsequent lookups.
value - - the object to store in the cache under this key

invalidate

void invalidate(java.lang.Object key)
Invalidate a cache key. This removes any object from the cache which might be stored under this key.

If the cache implementation is cluster aware this call also invalidates the given key on all instances of this cache in the cluster


clear

void clear()
Clear the cache. Remove all objects stored in the cache. This call implies an invalidate() for each key in the cache.