org.infinispan.client.hotrod.impl
Class RemoteCacheImpl<K,V>

java.lang.Object
  extended by org.infinispan.CacheSupport<K,V>
      extended by org.infinispan.client.hotrod.impl.RemoteCacheSupport<K,V>
          extended by org.infinispan.client.hotrod.impl.RemoteCacheImpl<K,V>
All Implemented Interfaces:
ConcurrentMap<K,V>, Map<K,V>, Cache<K,V>, RemoteCache<K,V>, Lifecycle, Listenable

public class RemoteCacheImpl<K,V>
extends RemoteCacheSupport<K,V>

// TODO: Document this

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

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.infinispan.client.hotrod.RemoteCache
RemoteCache.VersionedValue<V>
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
 
Fields inherited from class org.infinispan.CacheSupport
defaultLifespan, defaultMaxIdleTime
 
Constructor Summary
RemoteCacheImpl(HotrodOperations operations, HotrodMarshaller marshaller, String name)
           
 
Method Summary
 void clear()
           
 NotifyingFuture<Void> clearAsync()
          Asynchronous version of Map.clear().
 boolean containsKey(Object key)
           
 V get(Object key)
           
 String getName()
          Retrieves the name of the cache
 String getVersion()
          Retrieves the version of Infinispan
 RemoteCache.VersionedValue<V> getVersioned(K key)
          Returns the RemoteCache.VersionedValue associated to the supplied key param, or null if it doesn't exist.
 boolean ping()
          Returns true if the remote cluster can be reached, false otherwise.
 V put(K key, V 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<? extends K,? extends V> map, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
          Synthetic operation.
 NotifyingFuture<Void> putAllAsync(Map<? extends K,? extends V> data, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
          Synthetic operation.
 NotifyingFuture<V> putAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
          Asynchronous version of Cache.put(Object, Object, long, TimeUnit, long, TimeUnit).
 V putIfAbsent(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
          An overloaded form of ConcurrentMap.putIfAbsent(Object, Object), which takes in lifespan parameters.
 NotifyingFuture<V> putIfAbsentAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
          Asynchronous version of Cache.putIfAbsent(Object, Object, long, TimeUnit, long, TimeUnit).
 boolean remove(K key, long version)
          Removes the given entry only if its version matches the supplied version.
 V remove(Object key)
           
 NotifyingFuture<V> removeAsync(Object key)
          Asynchronous version of Map.remove(Object).
 NotifyingFuture<Boolean> removeAsync(Object key, long version)
           
 boolean replace(K key, V newValue, long version, int lifespanSeconds, int maxIdleTimeSeconds)
           
 V replace(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
          An overloaded form of ConcurrentMap.replace(Object, Object), which takes in lifespan parameters.
 NotifyingFuture<Boolean> replaceAsync(K key, V newValue, long version, int lifespanSeconds, int maxIdleSeconds)
           
 NotifyingFuture<V> replaceAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
          Asynchronous version of Cache.replace(Object, Object, long, TimeUnit, long, TimeUnit).
 void start()
           
 ServerStatistics stats()
           
 void stop()
           
 RemoteCache withFlags(Flag... flags)
           
 
Methods inherited from class org.infinispan.client.hotrod.impl.RemoteCacheSupport
addListener, compact, containsValue, endBatch, entrySet, evict, getAdvancedCache, getCacheManager, getConfiguration, getListeners, getStatus, isEmpty, keySet, putForExternalRead, remove, removeAsync, removeListener, replace, replace, replace, replaceAsync, replaceAsync, replaceAsync, size, startBatch, values
 
Methods inherited from class org.infinispan.CacheSupport
put, put, putAll, putAll, putAllAsync, putAllAsync, putAsync, putAsync, putIfAbsent, putIfAbsent, putIfAbsentAsync, putIfAbsentAsync, replace, replace, replace, replace, replaceAsync, replaceAsync, replaceAsync, replaceAsync
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.infinispan.client.hotrod.RemoteCache
putAll, putAll, putAllAsync, putAllAsync, replace, replace, replaceAsync, replaceAsync
 
Methods inherited from interface org.infinispan.Cache
put, putAsync, putAsync, putIfAbsent, putIfAbsentAsync, putIfAbsentAsync, replace, replaceAsync, replaceAsync
 
Methods inherited from interface java.util.concurrent.ConcurrentMap
putIfAbsent, replace
 
Methods inherited from interface java.util.Map
equals, hashCode, put
 

Constructor Detail

RemoteCacheImpl

public RemoteCacheImpl(HotrodOperations operations,
                       HotrodMarshaller marshaller,
                       String name)
Method Detail

remove

public boolean remove(K key,
                      long version)
Description copied from interface: RemoteCache
Removes the given entry only if its version matches the supplied version. A typical use case looks like this:
 VersionedEntry ve = remoteCache.getVersioned(key);
 //some processing
 remoteCache.remove(key, ve.getVersion();
 
Lat call (remove) will make sure that the entry will only be removed if it hasn't been changed in between.

Returns:
true if the entry has been removed
See Also:
RemoteCache.VersionedValue, RemoteCache.getVersioned(Object)

removeAsync

public NotifyingFuture<Boolean> removeAsync(Object key,
                                            long version)
See Also:
RemoteCache.remove(Object, Object)

replace

public boolean replace(K key,
                       V newValue,
                       long version,
                       int lifespanSeconds,
                       int maxIdleTimeSeconds)
See Also:
RemoteCache.replace(Object, Object, long)

replaceAsync

public NotifyingFuture<Boolean> replaceAsync(K key,
                                             V newValue,
                                             long version,
                                             int lifespanSeconds,
                                             int maxIdleSeconds)
See Also:
RemoteCache.replace(Object, Object, long)

getVersioned

public RemoteCache.VersionedValue<V> getVersioned(K key)
Description copied from interface: RemoteCache
Returns the RemoteCache.VersionedValue associated to the supplied key param, or null if it doesn't exist.


putAll

public void putAll(Map<? extends K,? extends V> map,
                   long lifespan,
                   TimeUnit lifespanUnit,
                   long maxIdleTime,
                   TimeUnit maxIdleTimeUnit)
Description copied from interface: RemoteCache
Synthetic operation.

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
See Also:
RemoteCache.putAll(java.util.Map, long, java.util.concurrent.TimeUnit)

putAllAsync

public NotifyingFuture<Void> putAllAsync(Map<? extends K,? extends V> data,
                                         long lifespan,
                                         TimeUnit lifespanUnit,
                                         long maxIdle,
                                         TimeUnit maxIdleUnit)
Description copied from interface: RemoteCache
Synthetic operation.

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
See Also:
RemoteCache.putAll(java.util.Map, long, java.util.concurrent.TimeUnit)

stats

public ServerStatistics stats()

getName

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

Returns:
the name of the cache

getVersion

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

Returns:
a version string

put

public V put(K key,
             V 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.

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 V putIfAbsent(K key,
                     V 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.

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 V replace(K key,
                 V 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.

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.

putAsync

public NotifyingFuture<V> putAsync(K key,
                                   V 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.

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

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.

Returns:
a future containing a void return type

putIfAbsentAsync

public NotifyingFuture<V> putIfAbsentAsync(K key,
                                           V 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.

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<V> 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.

Parameters:
key - key to remove
Returns:
a future containing the value removed

replaceAsync

public NotifyingFuture<V> replaceAsync(K key,
                                       V 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.

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

containsKey

public boolean containsKey(Object key)

get

public V get(Object key)

remove

public V remove(Object key)

clear

public void clear()

ping

public boolean ping()
Description copied from interface: RemoteCache
Returns true if the remote cluster can be reached, false otherwise.


start

public void start()

stop

public void stop()

withFlags

public RemoteCache withFlags(Flag... flags)

Google Analytics

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