org.infinispan
Class CacheSupport<K,V>

java.lang.Object
  extended by org.infinispan.CacheSupport<K,V>
All Implemented Interfaces:
ConcurrentMap<K,V>, Map<K,V>, BasicCache<K,V>, Lifecycle
Direct Known Subclasses:
CacheImpl, RemoteCacheSupport

public abstract class CacheSupport<K,V>
extends Object
implements BasicCache<K,V>

Since:
4.1
Author:
Mircea.Markus@jboss.com

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
protected  long defaultLifespan
           
protected  long defaultMaxIdleTime
           
 
Constructor Summary
protected CacheSupport()
           
protected CacheSupport(long defaultLifespan, long defaultMaxIdleTime)
           
 
Method Summary
 V put(K key, V value)
           
 V put(K key, V value, long lifespan, TimeUnit unit)
          An overloaded form of Map.put(Object, Object), which takes in lifespan parameters.
 void putAll(Map<? extends K,? extends V> map)
           
 void putAll(Map<? extends K,? extends V> map, long lifespan, TimeUnit unit)
          An overloaded form of Map.putAll(Map), which takes in lifespan parameters.
 NotifyingFuture<Void> putAllAsync(Map<? extends K,? extends V> data)
          Asynchronous version of Map.putAll(Map).
 NotifyingFuture<Void> putAllAsync(Map<? extends K,? extends V> data, long lifespan, TimeUnit unit)
          Asynchronous version of BasicCache.putAll(Map, long, TimeUnit).
 NotifyingFuture<V> putAsync(K key, V value)
          Asynchronous version of Map.put(Object, Object).
 NotifyingFuture<V> putAsync(K key, V value, long lifespan, TimeUnit unit)
          Asynchronous version of BasicCache.put(Object, Object, long, TimeUnit) .
 V putIfAbsent(K key, V value)
           
 V putIfAbsent(K key, V value, long lifespan, TimeUnit unit)
          An overloaded form of ConcurrentMap.putIfAbsent(Object, Object), which takes in lifespan parameters.
 NotifyingFuture<V> putIfAbsentAsync(K key, V value)
          Asynchronous version of ConcurrentMap.putIfAbsent(Object, Object).
 NotifyingFuture<V> putIfAbsentAsync(K key, V value, long lifespan, TimeUnit unit)
          Asynchronous version of BasicCache.putIfAbsent(Object, Object, long, TimeUnit) .
 V replace(K key, V value)
           
 V replace(K key, V value, long lifespan, TimeUnit unit)
          An overloaded form of ConcurrentMap.replace(Object, Object), which takes in lifespan parameters.
 boolean replace(K key, V oldValue, V newValue)
           
 boolean replace(K key, V oldValue, V value, long lifespan, TimeUnit unit)
          An overloaded form of ConcurrentMap.replace(Object, Object, Object), which takes in lifespan parameters.
 NotifyingFuture<V> replaceAsync(K key, V value)
          Asynchronous version of ConcurrentMap.replace(Object, Object).
 NotifyingFuture<V> replaceAsync(K key, V value, long lifespan, TimeUnit unit)
          Asynchronous version of BasicCache.replace(Object, Object, long, TimeUnit).
 NotifyingFuture<Boolean> replaceAsync(K key, V oldValue, V newValue)
          Asynchronous version of ConcurrentMap.replace(Object, Object, Object).
 NotifyingFuture<Boolean> replaceAsync(K key, V oldValue, V newValue, long lifespan, TimeUnit unit)
          Asynchronous version of BasicCache.replace(Object, Object, Object, long, TimeUnit).
protected abstract  void set(K key, V value)
          This is intentionally a non-public method meant as an integration point for bytecode manipulation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.infinispan.api.BasicCache
clearAsync, getAsync, getName, getVersion, put, putAll, putAllAsync, putAsync, putIfAbsent, putIfAbsentAsync, removeAsync, removeAsync, replace, replace, replaceAsync, replaceAsync
 
Methods inherited from interface java.util.concurrent.ConcurrentMap
remove
 
Methods inherited from interface java.util.Map
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, remove, size, values
 
Methods inherited from interface org.infinispan.lifecycle.Lifecycle
start, stop
 

Field Detail

defaultLifespan

protected long defaultLifespan

defaultMaxIdleTime

protected long defaultMaxIdleTime
Constructor Detail

CacheSupport

protected CacheSupport()

CacheSupport

protected CacheSupport(long defaultLifespan,
                       long defaultMaxIdleTime)
Method Detail

put

public final V put(K key,
                   V value)
Specified by:
put in interface Map<K,V>

set

protected abstract void set(K key,
                            V value)
This is intentionally a non-public method meant as an integration point for bytecode manipulation. Don't remove or alter the signature even if it might look like unreachable code. Implementors should perform a put operation but optimizing it as return values are not required.

Since:
5.0

putAll

public final void putAll(Map<? extends K,? extends V> map)
Specified by:
putAll in interface Map<K,V>

putAsync

public final NotifyingFuture<V> putAsync(K key,
                                         V value)
Description copied from interface: BasicCache
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 BasicCache<K,V>
Parameters:
key - key to use
value - value to store
Returns:
a future containing the old value replaced.

putIfAbsent

public final V putIfAbsent(K key,
                           V value)
Specified by:
putIfAbsent in interface ConcurrentMap<K,V>

putAsync

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

Specified by:
putAsync in interface BasicCache<K,V>
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

putAllAsync

public final NotifyingFuture<Void> putAllAsync(Map<? extends K,? extends V> data)
Description copied from interface: BasicCache
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 BasicCache<K,V>
Parameters:
data - to store
Returns:
a future containing a void return type

putAllAsync

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

Specified by:
putAllAsync in interface BasicCache<K,V>
Parameters:
data - to store
lifespan - lifespan of entry
unit - time unit for lifespan
Returns:
a future containing a void return type

putIfAbsentAsync

public final NotifyingFuture<V> putIfAbsentAsync(K key,
                                                 V value)
Description copied from interface: BasicCache
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 BasicCache<K,V>
Parameters:
key - key to use
value - value to store
Returns:
a future containing the old value replaced.

putIfAbsentAsync

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

Specified by:
putIfAbsentAsync in interface BasicCache<K,V>
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

replaceAsync

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

Specified by:
replaceAsync in interface BasicCache<K,V>
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 final NotifyingFuture<Boolean> replaceAsync(K key,
                                                   V oldValue,
                                                   V newValue)
Description copied from interface: BasicCache
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 BasicCache<K,V>
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 final NotifyingFuture<V> replaceAsync(K key,
                                             V value)
Description copied from interface: BasicCache
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 BasicCache<K,V>
Parameters:
key - key to remove
value - value to store
Returns:
a future containing the previous value overwritten

replaceAsync

public final NotifyingFuture<Boolean> replaceAsync(K key,
                                                   V oldValue,
                                                   V newValue,
                                                   long lifespan,
                                                   TimeUnit unit)
Description copied from interface: BasicCache
Asynchronous version of BasicCache.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 BasicCache.replace(Object, Object, Object, long, TimeUnit) if used in LOCAL mode.

Specified by:
replaceAsync in interface BasicCache<K,V>
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

put

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

Specified by:
put in interface BasicCache<K,V>
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 final V putIfAbsent(K key,
                           V value,
                           long lifespan,
                           TimeUnit unit)
Description copied from interface: BasicCache
An overloaded form of ConcurrentMap.putIfAbsent(Object, Object), which takes in lifespan parameters.

Specified by:
putIfAbsent in interface BasicCache<K,V>
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 final void putAll(Map<? extends K,? extends V> map,
                         long lifespan,
                         TimeUnit unit)
Description copied from interface: BasicCache
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 BasicCache<K,V>
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 final V replace(K key,
                       V value,
                       long lifespan,
                       TimeUnit unit)
Description copied from interface: BasicCache
An overloaded form of ConcurrentMap.replace(Object, Object), which takes in lifespan parameters.

Specified by:
replace in interface BasicCache<K,V>
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 final boolean replace(K key,
                             V oldValue,
                             V newValue)
Specified by:
replace in interface ConcurrentMap<K,V>

replace

public final V replace(K key,
                       V value)
Specified by:
replace in interface ConcurrentMap<K,V>

replace

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

Specified by:
replace in interface BasicCache<K,V>
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

-->

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