org.infinispan.tree
Class CacheAdapter

java.lang.Object
  extended by org.infinispan.tree.CacheAdapter
All Implemented Interfaces:
ConcurrentMap, Map, Cache, Lifecycle, Listenable

public class CacheAdapter
extends Object
implements Cache

A cache adapter for setting flags for each individual cache operation called within the scope of a TreeCache operation. Note: We can't just wrap around use of cache in tree module because flag assignment needs to extend even to calls within AtomicHashMapProxy.getDeltaMapForWrite(). So, the only possible way is to wrap around the Cache instance around something that sets flags accordingly.

Since:
4.2
Author:
Galder ZamarreƱo

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
CacheAdapter(Cache cache, TreeContextContainer tcc, InvocationContextContainer icc)
           
 
Method Summary
 void addListener(Object listener)
          Adds a listener to the component.
 void clear()
           
 NotifyingFuture<Void> clearAsync()
          Asynchronous version of Map.clear().
 void compact()
          Method that releases object references of cached objects held in the cache by serializing them to byte buffers.
 boolean containsKey(Object key)
           
 boolean containsValue(Object value)
           
 void endBatch(boolean successful)
          Completes a batch if one has been started using Cache.startBatch().
 Set entrySet()
          Returns a set view of the mappings contained in this cache.
 void evict(Object key)
          Evicts an entry from the memory of the cache.
 Object get(Object key)
           
 AdvancedCache getAdvancedCache()
           
 NotifyingFuture getAsync(Object key)
          Asynchronous version of Map.get(Object) that allows user code to retrieve the value associated with a key at a later stage, hence allowing multiple parallel get requests to be sent.
 EmbeddedCacheManager getCacheManager()
          Retrieves the cache manager responsible for creating this cache instance.
 Configuration getConfiguration()
           
 Set<Object> getListeners()
           
 String getName()
          Retrieves the name of the cache
 ComponentStatus getStatus()
           
 String getVersion()
          Retrieves the version of Infinispan
 boolean isEmpty()
           
 Set keySet()
          Returns a set view of the keys contained in this cache.
 Object put(Object key, Object value)
           
 Object put(Object key, Object value, long lifespan, TimeUnit unit)
          An overloaded form of Map.put(Object, Object), which takes in lifespan parameters.
 Object put(Object key, Object value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
          An overloaded form of Map.put(Object, Object), which takes in lifespan parameters.
 void putAll(Map m)
           
 void putAll(Map map, long lifespan, TimeUnit unit)
          An overloaded form of Map.putAll(Map), which takes in lifespan parameters.
 void putAll(Map map, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
          An overloaded form of Map.putAll(Map), which takes in lifespan parameters.
 NotifyingFuture<Void> putAllAsync(Map data)
          Asynchronous version of Map.putAll(Map).
 NotifyingFuture<Void> putAllAsync(Map data, long lifespan, TimeUnit unit)
          Asynchronous version of Cache.putAll(Map, long, TimeUnit).
 NotifyingFuture<Void> putAllAsync(Map data, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
          Asynchronous version of Cache.putAll(Map, long, TimeUnit, long, TimeUnit).
 NotifyingFuture putAsync(Object key, Object value)
          Asynchronous version of Map.put(Object, Object).
 NotifyingFuture putAsync(Object key, Object value, long lifespan, TimeUnit unit)
          Asynchronous version of Cache.put(Object, Object, long, TimeUnit) .
 NotifyingFuture putAsync(Object key, Object value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
          Asynchronous version of Cache.put(Object, Object, long, TimeUnit, long, TimeUnit).
 void putForExternalRead(Object key, Object value)
          Under special operating behavior, associates the value with the specified key.
 Object putIfAbsent(Object key, Object value)
           
 Object putIfAbsent(Object key, Object value, long lifespan, TimeUnit unit)
          An overloaded form of ConcurrentMap.putIfAbsent(Object, Object), which takes in lifespan parameters.
 Object putIfAbsent(Object key, Object value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
          An overloaded form of ConcurrentMap.putIfAbsent(Object, Object), which takes in lifespan parameters.
 NotifyingFuture putIfAbsentAsync(Object key, Object value)
          Asynchronous version of ConcurrentMap.putIfAbsent(Object, Object).
 NotifyingFuture putIfAbsentAsync(Object key, Object value, long lifespan, TimeUnit unit)
          Asynchronous version of Cache.putIfAbsent(Object, Object, long, TimeUnit) .
 NotifyingFuture putIfAbsentAsync(Object key, Object value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
          Asynchronous version of Cache.putIfAbsent(Object, Object, long, TimeUnit, long, TimeUnit).
 Object remove(Object key)
           
 boolean remove(Object key, Object value)
           
 NotifyingFuture removeAsync(Object key)
          Asynchronous version of Map.remove(Object).
 NotifyingFuture<Boolean> removeAsync(Object key, Object value)
          Asynchronous version of ConcurrentMap.remove(Object, Object).
 void removeListener(Object listener)
          Removes a listener from the component.
 Object replace(Object key, Object value)
           
 Object replace(Object key, Object value, long lifespan, TimeUnit unit)
          An overloaded form of ConcurrentMap.replace(Object, Object), which takes in lifespan parameters.
 Object replace(Object key, Object value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
          An overloaded form of ConcurrentMap.replace(Object, Object), which takes in lifespan parameters.
 boolean replace(Object key, Object oldValue, Object newValue)
           
 boolean replace(Object key, Object oldValue, Object value, long lifespan, TimeUnit unit)
          An overloaded form of ConcurrentMap.replace(Object, Object, Object), which takes in lifespan parameters.
 boolean replace(Object key, Object oldValue, Object value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
          An overloaded form of ConcurrentMap.replace(Object, Object, Object), which takes in lifespan parameters.
 NotifyingFuture replaceAsync(Object key, Object value)
          Asynchronous version of ConcurrentMap.replace(Object, Object).
 NotifyingFuture replaceAsync(Object key, Object value, long lifespan, TimeUnit unit)
          Asynchronous version of Cache.replace(Object, Object, long, TimeUnit).
 NotifyingFuture replaceAsync(Object key, Object value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
          Asynchronous version of Cache.replace(Object, Object, long, TimeUnit, long, TimeUnit).
 NotifyingFuture<Boolean> replaceAsync(Object key, Object oldValue, Object newValue)
          Asynchronous version of ConcurrentMap.replace(Object, Object, Object).
 NotifyingFuture<Boolean> replaceAsync(Object key, Object oldValue, Object newValue, long lifespan, TimeUnit unit)
          Asynchronous version of Cache.replace(Object, Object, Object, long, TimeUnit).
 NotifyingFuture<Boolean> replaceAsync(Object key, Object oldValue, Object newValue, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
          Asynchronous version of Cache.replace(Object, Object, Object, long, TimeUnit, long, TimeUnit).
 int size()
           
 void start()
           
 boolean startBatch()
          Starts a batch.
 void stop()
           
 Collection values()
          Returns a collection view of the values contained in this cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

CacheAdapter

public CacheAdapter(Cache cache,
                    TreeContextContainer tcc,
                    InvocationContextContainer icc)
Method Detail

putForExternalRead

public void putForExternalRead(Object key,
                               Object value)
Description copied from interface: Cache
Under special operating behavior, associates the value with the specified key. This method is for caching data that has an external representation in storage, where, concurrent modification and transactions are not a consideration, and failure to put the data in the cache should be treated as a 'suboptimal outcome' rather than a 'failing outcome'.

An example of when this method is useful is when data is read from, for example, a legacy datastore, and is cached before returning the data to the caller. Subsequent calls would prefer to get the data from the cache and if the data doesn't exist in the cache, fetch again from the legacy datastore.

See JBCACHE-848 for details around this feature.

Specified by:
putForExternalRead in interface Cache
Parameters:
key - key with which the specified value is to be associated.
value - value to be associated with the specified key.

evict

public void evict(Object key)
Description copied from interface: Cache
Evicts an entry from the memory of the cache. Note that the entry is not removed from any configured cache stores or any other caches in the cluster (if used in a clustered mode). Use Map.remove(Object) to remove an entry from the entire cache system.

This method is designed to evict an entry from memory to free up memory used by the application. This method uses a 0 lock acquisition timeout so it does not block in attempting to acquire locks. It behaves as a no-op if the lock on the entry cannot be acquired immediately.

Important: this method should not be called from within a transaction scope.

Specified by:
evict in interface Cache
Parameters:
key - key to evict

getConfiguration

public Configuration getConfiguration()
Specified by:
getConfiguration in interface Cache

startBatch

public boolean startBatch()
Description copied from interface: Cache
Starts a batch. All operations on the current client thread are performed as a part of this batch, with locks held for the duration of the batch and any remote calls delayed till the end of the batch.

Specified by:
startBatch in interface Cache
Returns:
true if a batch was successfully started; false if one was available and already running.

endBatch

public void endBatch(boolean successful)
Description copied from interface: Cache
Completes a batch if one has been started using Cache.startBatch(). If no batch has been started, this is a no-op.

Specified by:
endBatch in interface Cache
Parameters:
successful - if true, the batch completes, otherwise the batch is aborted and changes are not committed.

getName

public String getName()
Description copied from interface: Cache
Retrieves the name of the cache

Specified by:
getName in interface Cache
Returns:
the name of the cache

getVersion

public String getVersion()
Description copied from interface: Cache
Retrieves the version of Infinispan

Specified by:
getVersion in interface Cache
Returns:
a version string

getCacheManager

public EmbeddedCacheManager getCacheManager()
Description copied from interface: Cache
Retrieves the cache manager responsible for creating this cache instance.

Specified by:
getCacheManager in interface Cache
Returns:
a cache manager

put

public Object put(Object key,
                  Object value,
                  long lifespan,
                  TimeUnit unit)
Description copied from interface: Cache
An overloaded form of Map.put(Object, Object), which takes in lifespan parameters.

Specified by:
put in interface Cache
Parameters:
key - key to use
value - value to store
lifespan - lifespan of the entry. Negative values are interpreted as unlimited lifespan.
unit - unit of measurement for the lifespan
Returns:
the value being replaced, or null if nothing is being replaced.

putIfAbsent

public Object putIfAbsent(Object key,
                          Object value,
                          long lifespan,
                          TimeUnit unit)
Description copied from interface: Cache
An overloaded form of ConcurrentMap.putIfAbsent(Object, Object), which takes in lifespan parameters.

Specified by:
putIfAbsent in interface Cache
Parameters:
key - key to use
value - value to store
lifespan - lifespan of the entry. Negative values are interpreted as unlimited lifespan.
unit - unit of measurement for the lifespan
Returns:
the value being replaced, or null if nothing is being replaced.

putAll

public void putAll(Map map,
                   long lifespan,
                   TimeUnit unit)
Description copied from interface: Cache
An overloaded form of Map.putAll(Map), which takes in lifespan parameters. Note that the lifespan is applied to all mappings in the map passed in.

Specified by:
putAll in interface Cache
Parameters:
map - map containing mappings to enter
lifespan - lifespan of the entry. Negative values are interpreted as unlimited lifespan.
unit - unit of measurement for the lifespan

replace

public Object replace(Object key,
                      Object value,
                      long lifespan,
                      TimeUnit unit)
Description copied from interface: Cache
An overloaded form of ConcurrentMap.replace(Object, Object), which takes in lifespan parameters.

Specified by:
replace in interface Cache
Parameters:
key - key to use
value - value to store
lifespan - lifespan of the entry. Negative values are interpreted as unlimited lifespan.
unit - unit of measurement for the lifespan
Returns:
the value being replaced, or null if nothing is being replaced.

replace

public boolean replace(Object key,
                       Object oldValue,
                       Object value,
                       long lifespan,
                       TimeUnit unit)
Description copied from interface: Cache
An overloaded form of ConcurrentMap.replace(Object, Object, Object), which takes in lifespan parameters.

Specified by:
replace in interface Cache
Parameters:
key - key to use
oldValue - value to replace
value - value to store
lifespan - lifespan of the entry. Negative values are interpreted as unlimited lifespan.
unit - unit of measurement for the lifespan
Returns:
true if the value was replaced, false otherwise

put

public Object put(Object key,
                  Object value,
                  long lifespan,
                  TimeUnit lifespanUnit,
                  long maxIdleTime,
                  TimeUnit maxIdleTimeUnit)
Description copied from interface: Cache
An overloaded form of Map.put(Object, Object), which takes in lifespan parameters.

Specified by:
put in interface Cache
Parameters:
key - key to use
value - value to store
lifespan - lifespan of the entry. Negative values are interpreted as unlimited lifespan.
lifespanUnit - time unit for lifespan
maxIdleTime - the maximum amount of time this key is allowed to be idle for before it is considered as expired
maxIdleTimeUnit - time unit for max idle time
Returns:
the value being replaced, or null if nothing is being replaced.

putIfAbsent

public Object putIfAbsent(Object key,
                          Object value,
                          long lifespan,
                          TimeUnit lifespanUnit,
                          long maxIdleTime,
                          TimeUnit maxIdleTimeUnit)
Description copied from interface: Cache
An overloaded form of ConcurrentMap.putIfAbsent(Object, Object), which takes in lifespan parameters.

Specified by:
putIfAbsent in interface Cache
Parameters:
key - key to use
value - value to store
lifespan - lifespan of the entry. Negative values are interpreted as unlimited lifespan.
lifespanUnit - time unit for lifespan
maxIdleTime - the maximum amount of time this key is allowed to be idle for before it is considered as expired
maxIdleTimeUnit - time unit for max idle time
Returns:
the value being replaced, or null if nothing is being replaced.

putAll

public void putAll(Map map,
                   long lifespan,
                   TimeUnit lifespanUnit,
                   long maxIdleTime,
                   TimeUnit maxIdleTimeUnit)
Description copied from interface: Cache
An overloaded form of Map.putAll(Map), which takes in lifespan parameters. Note that the lifespan is applied to all mappings in the map passed in.

Specified by:
putAll in interface Cache
Parameters:
map - map containing mappings to enter
lifespan - lifespan of the entry. Negative values are interpreted as unlimited lifespan.
lifespanUnit - time unit for lifespan
maxIdleTime - the maximum amount of time this key is allowed to be idle for before it is considered as expired
maxIdleTimeUnit - time unit for max idle time

replace

public Object replace(Object key,
                      Object value,
                      long lifespan,
                      TimeUnit lifespanUnit,
                      long maxIdleTime,
                      TimeUnit maxIdleTimeUnit)
Description copied from interface: Cache
An overloaded form of ConcurrentMap.replace(Object, Object), which takes in lifespan parameters.

Specified by:
replace in interface Cache
Parameters:
key - key to use
value - value to store
lifespan - lifespan of the entry. Negative values are interpreted as unlimited lifespan.
lifespanUnit - time unit for lifespan
maxIdleTime - the maximum amount of time this key is allowed to be idle for before it is considered as expired
maxIdleTimeUnit - time unit for max idle time
Returns:
the value being replaced, or null if nothing is being replaced.

replace

public boolean replace(Object key,
                       Object oldValue,
                       Object value,
                       long lifespan,
                       TimeUnit lifespanUnit,
                       long maxIdleTime,
                       TimeUnit maxIdleTimeUnit)
Description copied from interface: Cache
An overloaded form of ConcurrentMap.replace(Object, Object, Object), which takes in lifespan parameters.

Specified by:
replace in interface Cache
Parameters:
key - key to use
oldValue - value to replace
value - value to store
lifespan - lifespan of the entry. Negative values are interpreted as unlimited lifespan.
lifespanUnit - time unit for lifespan
maxIdleTime - the maximum amount of time this key is allowed to be idle for before it is considered as expired
maxIdleTimeUnit - time unit for max idle time
Returns:
true if the value was replaced, false otherwise

putAsync

public NotifyingFuture putAsync(Object key,
                                Object value)
Description copied from interface: Cache
Asynchronous version of Map.put(Object, Object). This method does not block on remote calls, even if your cache mode is synchronous. Has no benefit over Map.put(Object, Object) if used in LOCAL mode.

Specified by:
putAsync in interface Cache
Parameters:
key - key to use
value - value to store
Returns:
a future containing the old value replaced.

putAsync

public NotifyingFuture putAsync(Object key,
                                Object value,
                                long lifespan,
                                TimeUnit unit)
Description copied from interface: Cache
Asynchronous version of Cache.put(Object, Object, long, TimeUnit) . This method does not block on remote calls, even if your cache mode is synchronous. Has no benefit over Cache.put(Object, Object, long, TimeUnit) if used in LOCAL mode.

Specified by:
putAsync in interface Cache
Parameters:
key - key to use
value - value to store
lifespan - lifespan of entry
unit - time unit for lifespan
Returns:
a future containing the old value replaced

putAsync

public NotifyingFuture putAsync(Object key,
                                Object value,
                                long lifespan,
                                TimeUnit lifespanUnit,
                                long maxIdle,
                                TimeUnit maxIdleUnit)
Description copied from interface: Cache
Asynchronous version of Cache.put(Object, Object, long, TimeUnit, long, TimeUnit). This method does not block on remote calls, even if your cache mode is synchronous. Has no benefit over Cache.put(Object, Object, long, TimeUnit, long, TimeUnit) if used in LOCAL mode.

Specified by:
putAsync in interface Cache
Parameters:
key - key to use
value - value to store
lifespan - lifespan of entry
lifespanUnit - time unit for lifespan
maxIdle - the maximum amount of time this key is allowed to be idle for before it is considered as expired
maxIdleUnit - time unit for max idle time
Returns:
a future containing the old value replaced

putAllAsync

public NotifyingFuture<Void> putAllAsync(Map data)
Description copied from interface: Cache
Asynchronous version of Map.putAll(Map). This method does not block on remote calls, even if your cache mode is synchronous. Has no benefit over Map.putAll(Map) if used in LOCAL mode.

Specified by:
putAllAsync in interface Cache
Parameters:
data - to store
Returns:
a future containing a void return type

putAllAsync

public NotifyingFuture<Void> putAllAsync(Map data,
                                         long lifespan,
                                         TimeUnit unit)
Description copied from interface: Cache
Asynchronous version of Cache.putAll(Map, long, TimeUnit). This method does not block on remote calls, even if your cache mode is synchronous. Has no benefit over Cache.putAll(Map, long, TimeUnit) if used in LOCAL mode.

Specified by:
putAllAsync in interface Cache
Parameters:
data - to store
lifespan - lifespan of entry
unit - time unit for lifespan
Returns:
a future containing a void return type

putAllAsync

public NotifyingFuture<Void> putAllAsync(Map data,
                                         long lifespan,
                                         TimeUnit lifespanUnit,
                                         long maxIdle,
                                         TimeUnit maxIdleUnit)
Description copied from interface: Cache
Asynchronous version of Cache.putAll(Map, long, TimeUnit, long, TimeUnit). This method does not block on remote calls, even if your cache mode is synchronous. Has no benefit over Cache.putAll(Map, long, TimeUnit, long, TimeUnit) if used in LOCAL mode.

Specified by:
putAllAsync in interface Cache
Parameters:
data - to store
lifespan - lifespan of entry
lifespanUnit - time unit for lifespan
maxIdle - the maximum amount of time this key is allowed to be idle for before it is considered as expired
maxIdleUnit - time unit for max idle time
Returns:
a future containing a void return type

clearAsync

public NotifyingFuture<Void> clearAsync()
Description copied from interface: Cache
Asynchronous version of Map.clear(). This method does not block on remote calls, even if your cache mode is synchronous. Has no benefit over Map.clear() if used in LOCAL mode.

Specified by:
clearAsync in interface Cache
Returns:
a future containing a void return type

putIfAbsentAsync

public NotifyingFuture putIfAbsentAsync(Object key,
                                        Object value)
Description copied from interface: Cache
Asynchronous version of ConcurrentMap.putIfAbsent(Object, Object). This method does not block on remote calls, even if your cache mode is synchronous. Has no benefit over ConcurrentMap.putIfAbsent(Object, Object) if used in LOCAL mode.

Specified by:
putIfAbsentAsync in interface Cache
Parameters:
key - key to use
value - value to store
Returns:
a future containing the old value replaced.

putIfAbsentAsync

public NotifyingFuture putIfAbsentAsync(Object key,
                                        Object value,
                                        long lifespan,
                                        TimeUnit unit)
Description copied from interface: Cache
Asynchronous version of Cache.putIfAbsent(Object, Object, long, TimeUnit) . This method does not block on remote calls, even if your cache mode is synchronous. Has no benefit over Cache.putIfAbsent(Object, Object, long, TimeUnit) if used in LOCAL mode.

Specified by:
putIfAbsentAsync in interface Cache
Parameters:
key - key to use
value - value to store
lifespan - lifespan of entry
unit - time unit for lifespan
Returns:
a future containing the old value replaced

putIfAbsentAsync

public NotifyingFuture putIfAbsentAsync(Object key,
                                        Object value,
                                        long lifespan,
                                        TimeUnit lifespanUnit,
                                        long maxIdle,
                                        TimeUnit maxIdleUnit)
Description copied from interface: Cache
Asynchronous version of Cache.putIfAbsent(Object, Object, long, TimeUnit, long, TimeUnit). This method does not block on remote calls, even if your cache mode is synchronous. Has no benefit over Cache.putIfAbsent(Object, Object, long, TimeUnit, long, TimeUnit) if used in LOCAL mode.

Specified by:
putIfAbsentAsync in interface Cache
Parameters:
key - key to use
value - value to store
lifespan - lifespan of entry
lifespanUnit - time unit for lifespan
maxIdle - the maximum amount of time this key is allowed to be idle for before it is considered as expired
maxIdleUnit - time unit for max idle time
Returns:
a future containing the old value replaced

removeAsync

public NotifyingFuture removeAsync(Object key)
Description copied from interface: Cache
Asynchronous version of Map.remove(Object). This method does not block on remote calls, even if your cache mode is synchronous. Has no benefit over Map.remove(Object) if used in LOCAL mode.

Specified by:
removeAsync in interface Cache
Parameters:
key - key to remove
Returns:
a future containing the value removed

removeAsync

public NotifyingFuture<Boolean> removeAsync(Object key,
                                            Object value)
Description copied from interface: Cache
Asynchronous version of ConcurrentMap.remove(Object, Object). This method does not block on remote calls, even if your cache mode is synchronous. Has no benefit over ConcurrentMap.remove(Object, Object) if used in LOCAL mode.

Specified by:
removeAsync in interface Cache
Parameters:
key - key to remove
value - value to match on
Returns:
a future containing a boolean, indicating whether the entry was removed or not

replaceAsync

public NotifyingFuture replaceAsync(Object key,
                                    Object value)
Description copied from interface: Cache
Asynchronous version of ConcurrentMap.replace(Object, Object). This method does not block on remote calls, even if your cache mode is synchronous. Has no benefit over ConcurrentMap.replace(Object, Object) if used in LOCAL mode.

Specified by:
replaceAsync in interface Cache
Parameters:
key - key to remove
value - value to store
Returns:
a future containing the previous value overwritten

replaceAsync

public NotifyingFuture replaceAsync(Object key,
                                    Object value,
                                    long lifespan,
                                    TimeUnit unit)
Description copied from interface: Cache
Asynchronous version of Cache.replace(Object, Object, long, TimeUnit). This method does not block on remote calls, even if your cache mode is synchronous. Has no benefit over Cache.replace(Object, Object, long, TimeUnit) if used in LOCAL mode.

Specified by:
replaceAsync in interface Cache
Parameters:
key - key to remove
value - value to store
lifespan - lifespan of entry
unit - time unit for lifespan
Returns:
a future containing the previous value overwritten

replaceAsync

public NotifyingFuture replaceAsync(Object key,
                                    Object value,
                                    long lifespan,
                                    TimeUnit lifespanUnit,
                                    long maxIdle,
                                    TimeUnit maxIdleUnit)
Description copied from interface: Cache
Asynchronous version of Cache.replace(Object, Object, long, TimeUnit, long, TimeUnit). This method does not block on remote calls, even if your cache mode is synchronous. Has no benefit over Cache.replace(Object, Object, long, TimeUnit, long, TimeUnit) if used in LOCAL mode.

Specified by:
replaceAsync in interface Cache
Parameters:
key - key to remove
value - value to store
lifespan - lifespan of entry
lifespanUnit - time unit for lifespan
maxIdle - the maximum amount of time this key is allowed to be idle for before it is considered as expired
maxIdleUnit - time unit for max idle time
Returns:
a future containing the previous value overwritten

replaceAsync

public NotifyingFuture<Boolean> replaceAsync(Object key,
                                             Object oldValue,
                                             Object newValue)
Description copied from interface: Cache
Asynchronous version of ConcurrentMap.replace(Object, Object, Object). This method does not block on remote calls, even if your cache mode is synchronous. Has no benefit over ConcurrentMap.replace(Object, Object, Object) if used in LOCAL mode.

Specified by:
replaceAsync in interface Cache
Parameters:
key - key to remove
oldValue - value to overwrite
newValue - value to store
Returns:
a future containing a boolean, indicating whether the entry was replaced or not

replaceAsync

public NotifyingFuture<Boolean> replaceAsync(Object key,
                                             Object oldValue,
                                             Object newValue,
                                             long lifespan,
                                             TimeUnit unit)
Description copied from interface: Cache
Asynchronous version of Cache.replace(Object, Object, Object, long, TimeUnit). This method does not block on remote calls, even if your cache mode is synchronous. Has no benefit over Cache.replace(Object, Object, Object, long, TimeUnit) if used in LOCAL mode.

Specified by:
replaceAsync in interface Cache
Parameters:
key - key to remove
oldValue - value to overwrite
newValue - value to store
lifespan - lifespan of entry
unit - time unit for lifespan
Returns:
a future containing a boolean, indicating whether the entry was replaced or not

replaceAsync

public NotifyingFuture<Boolean> replaceAsync(Object key,
                                             Object oldValue,
                                             Object newValue,
                                             long lifespan,
                                             TimeUnit lifespanUnit,
                                             long maxIdle,
                                             TimeUnit maxIdleUnit)
Description copied from interface: Cache
Asynchronous version of Cache.replace(Object, Object, Object, long, TimeUnit, long, TimeUnit). This method does not block on remote calls, even if your cache mode is synchronous. Has no benefit over Cache.replace(Object, Object, Object, long, TimeUnit, long, TimeUnit) if used in LOCAL mode.

Specified by:
replaceAsync in interface Cache
Parameters:
key - key to remove
oldValue - value to overwrite
newValue - value to store
lifespan - lifespan of entry
lifespanUnit - time unit for lifespan
maxIdle - the maximum amount of time this key is allowed to be idle for before it is considered as expired
maxIdleUnit - time unit for max idle time
Returns:
a future containing a boolean, indicating whether the entry was replaced or not

getAdvancedCache

public AdvancedCache getAdvancedCache()
Specified by:
getAdvancedCache in interface Cache

compact

public void compact()
Description copied from interface: Cache
Method that releases object references of cached objects held in the cache by serializing them to byte buffers. Cached objects are lazily de-serialized when accessed again, based on the calling thread's context class loader.

This can be expensive, based on the effort required to serialize cached objects.

Specified by:
compact in interface Cache

getStatus

public ComponentStatus getStatus()
Specified by:
getStatus in interface Cache

size

public int size()
Specified by:
size in interface Map

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Map

containsKey

public boolean containsKey(Object key)
Specified by:
containsKey in interface Map

containsValue

public boolean containsValue(Object value)
Specified by:
containsValue in interface Map

get

public Object get(Object key)
Specified by:
get in interface Map

put

public Object put(Object key,
                  Object value)
Specified by:
put in interface Map

remove

public Object remove(Object key)
Specified by:
remove in interface Map

putAll

public void putAll(Map m)
Specified by:
putAll in interface Map

clear

public void clear()
Specified by:
clear in interface Map

keySet

public Set keySet()
Description copied from interface: Cache
Returns a set view of the keys contained in this cache. This set is immutable, so it cannot be modified and changes to the cache won't be reflected in the set. When this method is called on a cache configured with distribution mode, the set returned only contains the keys locally available in the cache instance. To avoid memory issues, there will be not attempt to bring keys from other nodes.

This method should only be used for debugging purposes such as to verify that the cache contains all the keys entered. Any other use involving execution of this method on a production system is not recommended.

Specified by:
keySet in interface Map
Specified by:
keySet in interface Cache
Returns:
a set view of the keys contained in this cache.

values

public Collection values()
Description copied from interface: Cache
Returns a collection view of the values contained in this cache. This collection is immutable, so it cannot be modified and changes to the cache won't be reflected in the set. When this method is called on a cache configured with distribution mode, the collection returned only contains the values locally available in the cache instance. To avoid memory issues, there is not attempt to bring values from other nodes.

This method should only be used for testing or debugging purposes such as to verify that the cache contains all the values entered. Any other use involving execution of this method on a production system is not recommended.

Specified by:
values in interface Map
Specified by:
values in interface Cache
Returns:
a collection view of the values contained in this map.

entrySet

public Set entrySet()
Description copied from interface: Cache
Returns a set view of the mappings contained in this cache. This set is immutable, so it cannot be modified and changes to the cache won't be reflected in the set. Besides, each element in the returned set is an immutable Map.Entry. When this method is called on a cache configured with distribution mode, the set returned only contains the mappings locally available in the cache instance. To avoid memory issues, there will be not attempt to bring mappings from other nodes.

This method should only be used for debugging purposes such as to verify that the cache contains all the mappings entered. Any other use involving execution of this method on a production system is not recommended.

Specified by:
entrySet in interface Map
Specified by:
entrySet in interface Cache
Returns:
a set view of the mappings contained in this cache.

putIfAbsent

public Object putIfAbsent(Object key,
                          Object value)
Specified by:
putIfAbsent in interface ConcurrentMap

remove

public boolean remove(Object key,
                      Object value)
Specified by:
remove in interface ConcurrentMap

replace

public boolean replace(Object key,
                       Object oldValue,
                       Object newValue)
Specified by:
replace in interface ConcurrentMap

replace

public Object replace(Object key,
                      Object value)
Specified by:
replace in interface ConcurrentMap

start

public void start()
Specified by:
start in interface Lifecycle

stop

public void stop()
Specified by:
stop in interface Lifecycle

addListener

public void addListener(Object listener)
Description copied from interface: Listenable
Adds a listener to the component. Typically, listeners would need to be annotated with Listener and further to that, contain methods annotated appropriately, otherwise the listener will not be registered.

See the Listener annotation for more information.

Specified by:
addListener in interface Listenable
Parameters:
listener - must not be null.

removeListener

public void removeListener(Object listener)
Description copied from interface: Listenable
Removes a listener from the component.

Specified by:
removeListener in interface Listenable
Parameters:
listener - listener to remove. Must not be null.

getListeners

public Set<Object> getListeners()
Specified by:
getListeners in interface Listenable
Returns:
a set of all listeners registered on this component.

getAsync

public NotifyingFuture getAsync(Object key)
Description copied from interface: Cache
Asynchronous version of Map.get(Object) that allows user code to retrieve the value associated with a key at a later stage, hence allowing multiple parallel get requests to be sent. Normally, when this method detects that the value is likely to be retrieved from from a remote entity, it will span a different thread in order to allow the asynchronous get call to return immediately. If the call will definitely resolve locally, for example when the cache is configured with LOCAL mode and no cache loaders are configured, the get asynchronous call will act sequentially and will have no different to Map.get(Object).

Specified by:
getAsync in interface Cache
Parameters:
key - key to retrieve
Returns:
a future that can be used to retrieve value associated with the key when this is available. The actual value returned by the future follows the same rules as Map.get(Object)

-->

Copyright © 2011 JBoss, a division of Red Hat. All Rights Reserved.