com.metamatrix.cache
Interface Cache<K,V>

All Known Implementing Classes:
JBossCache

public interface Cache<K,V>

Abstraction over cache providers


Nested Class Summary
static class Cache.Type
           
 
Method Summary
 Cache addChild(java.lang.String name)
          Add a child node to the current cache node
 void addListener(CacheListener listener)
          Listener to get the updates on this Cache
 void clear()
          Removes all the keys and their values from the Cache
 V get(K key)
          Retrieves the value for the given Key
 Cache getChild(java.lang.String name)
          Get the child cache node from the current node
 java.util.List<Cache> getChildren()
          Get child nodes under this cache node.
 java.lang.String getName()
          Name of the cache node
 java.util.Set<K> keySet()
          Returns a Set containing the data in this Cache
 V put(K key, V value)
          Associates the specified value with the specified key this cache.
 V remove(K key)
          Removes the value for this key from a Cache.
 boolean removeChild(java.lang.String name)
          Destroys the child from the current node; no-op if node not found
 void removeListener()
          Remove Listener to stop the updates on this Cache
 int size()
          Size of the cache
 java.util.Collection<V> values()
          Returns a Collection containing the data in this Cache
 

Method Detail

get

V get(K key)
Retrieves the value for the given Key

Parameters:
key - key under which value is to be retrieved.
Returns:
returns data held under specified key in cache

put

V put(K key,
      V value)
Associates the specified value with the specified key this cache. If the cache previously contained a mapping for this key, the old value is replaced by the specified value.

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

remove

V remove(K key)
Removes the value for this key from a Cache. Returns the value to which the Key previously associated , or null if the Key contained no mapping.

Parameters:
key - key whose mapping is to be removed
Returns:
previous value associated with specified Node's key

size

int size()
Size of the cache

Returns:
number of items in this cache

keySet

java.util.Set<K> keySet()
Returns a Set containing the data in this Cache

Returns:
a Set containing the data in this Cache. If there is no data, an empty Set is returned. The Set returned is always immutable.

clear

void clear()
Removes all the keys and their values from the Cache


addListener

void addListener(CacheListener listener)
Listener to get the updates on this Cache

Parameters:
listener -

removeListener

void removeListener()
Remove Listener to stop the updates on this Cache

Parameters:
listener -

values

java.util.Collection<V> values()
Returns a Collection containing the data in this Cache

Returns:
a Collection containing the data in this Cache. If there is no data, an empty Collection is returned.

addChild

Cache addChild(java.lang.String name)
Add a child node to the current cache node

Parameters:
name - - name of the child
Returns:
Cache instance.

getChild

Cache getChild(java.lang.String name)
Get the child cache node from the current node

Parameters:
name -
Returns:
null if not found

removeChild

boolean removeChild(java.lang.String name)
Destroys the child from the current node; no-op if node not found

Parameters:
name -
Returns:
true if removed; false otherwise

getChildren

java.util.List<Cache> getChildren()
Get child nodes under this cache node. If none found empty set is returned

Returns:

getName

java.lang.String getName()
Name of the cache node

Returns:


Copyright © 2009. All Rights Reserved.