org.teiid.cache.jboss
Class JBossCache<K,V>

java.lang.Object
  extended by org.teiid.cache.jboss.JBossCache<K,V>
All Implemented Interfaces:
Cache<K,V>
Direct Known Subclasses:
ExpirationAwareCache

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

Implementation of Cache using JBoss Cache


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.teiid.cache.Cache
Cache.Type
 
Field Summary
protected  JBossCacheListener cacheListener
           
protected  org.jboss.cache.Cache<K,V> cacheStore
           
protected  CacheConfiguration config
           
protected  org.jboss.cache.Fqn rootFqn
           
 
Constructor Summary
JBossCache(org.jboss.cache.Cache<K,V> cacheStore, org.jboss.cache.Fqn fqn)
           
 
Method Summary
 void addListener(CacheListener listener)
           
 void clear()
          Removes all the keys and their values from the Cache
 V get(K key)
          Retrieves the value for the given Key
protected  org.jboss.cache.Fqn<java.lang.String> getFqn(K key)
           
 java.lang.String getName()
          Name of the cache node
protected  org.jboss.cache.Node<K,V> getRootNode()
           
 java.util.Set<K> keys()
          Return all the keys
 V put(K key, V value)
           
 V put(K key, V value, java.lang.Long ttl)
          Associates the specified value with the specified key this cache.
 V remove(K key)
          Removes the value for this key from a Cache.
 void removeListener()
           
 int size()
          Size of the cache
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cacheStore

protected org.jboss.cache.Cache<K,V> cacheStore

rootFqn

protected org.jboss.cache.Fqn rootFqn

cacheListener

protected JBossCacheListener cacheListener

config

protected CacheConfiguration config
Constructor Detail

JBossCache

public JBossCache(org.jboss.cache.Cache<K,V> cacheStore,
                  org.jboss.cache.Fqn fqn)
Method Detail

get

public V get(K key)
Description copied from interface: Cache
Retrieves the value for the given Key

Specified by:
get in interface Cache<K,V>
Parameters:
key - key under which value is to be retrieved.
Returns:
returns data held under specified key in cache

getFqn

protected org.jboss.cache.Fqn<java.lang.String> getFqn(K key)

put

public V put(K key,
             V value)

put

public V put(K key,
             V value,
             java.lang.Long ttl)
Description copied from interface: Cache
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.

Specified by:
put in interface Cache<K,V>
Parameters:
key - key with which the specified value is to be associated.
value - value to be associated with the specified key.
ttl - the time for this entry to live
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

public V remove(K key)
Description copied from interface: Cache
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.

Specified by:
remove in interface Cache<K,V>
Parameters:
key - key whose mapping is to be removed
Returns:
previous value associated with specified Node's key

size

public int size()
Description copied from interface: Cache
Size of the cache

Specified by:
size in interface Cache<K,V>
Returns:
number of items in this cache

clear

public void clear()
Description copied from interface: Cache
Removes all the keys and their values from the Cache

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

addListener

public void addListener(CacheListener listener)

removeListener

public void removeListener()

getRootNode

protected org.jboss.cache.Node<K,V> getRootNode()

getName

public java.lang.String getName()
Description copied from interface: Cache
Name of the cache node

Specified by:
getName in interface Cache<K,V>
Returns:

keys

public java.util.Set<K> keys()
Description copied from interface: Cache
Return all the keys

Specified by:
keys in interface Cache<K,V>
Returns:


Copyright © 2010. All Rights Reserved.