public interface RemoteCache<K,V> extends BasicCache<K,V>
Cache, but given its
nature (remote) some operations are not supported. All these unsupported operations are being overridden within this
interface and documented as such.
New operations: besides the operations inherited from Cache, RemoteCache also adds new
operations to optimize/reduce network traffic: e.g. versioned put operation.
Concurrency: implementors of this interface will support multi-threaded access, similar to the way Cache supports it.
Return values: previously existing values for certain Map operations are not returned, null
is returned instead. E.g. Map.put(Object, Object) returns the previous value associated to the
supplied key. In case of RemoteCache, this returns null.
Synthetic operations: aggregate operations are being implemented based on other Hot Rod operations. E.g. all
the Map.putAll(java.util.Map) is implemented through multiple individual puts. This means that the
these operations are not atomic and that they are costly, e.g. as the number of network round-trips is not one, but
the size of the added map. All these synthetic operations are documented as such.
changing default behavior through Flags: it is possible to change the
default cache behaviour by using flags on an per invocation basis. E.g.
RemoteCache cache = getRemoteCache();
Object oldValue = cache.withFlags(Flag.FORCE_RETURN_VALUE).put(aKey, aValue);
In the previous example, using Flag.FORCE_RETURN_VALUE will make the client to
also return previously existing value associated with aKey. If this flag would not be present, Infinispan
would return (by default) null. This is in order to avoid fetching a possibly large object from the remote
server, which might not be needed. The flags as set by the withFlags(Flag...)
operation only apply for the very next operation executed by the same thread on the RemoteCache.
Eviction and expiration: Unlike local Cache cache, which allows specifying time values with any granularity (as defined by TimeUnit), HotRod only supports seconds as time units. If a different time unit is used instead, HotRod will
transparently convert it to seconds, using TimeUnit.toSeconds(long) method. This might
result in loss of precision for values specified as nanos or milliseconds. | Modifier and Type | Method and Description |
|---|---|
boolean |
containsValue(Object value) |
Set<Map.Entry<K,V>> |
entrySet() |
Map<K,V> |
getBulk()
Bulk get operations, returns all the entries within the remote cache.
|
Map<K,V> |
getBulk(int size)
Same as
getBulk(), but limits the returned set of values to the specified size. |
RemoteCacheManager |
getRemoteCacheManager()
Returns the
RemoteCacheManager that created this cache. |
VersionedValue<V> |
getVersioned(K key)
Returns the
VersionedValue associated to the supplied key param, or null if it doesn't exist. |
MetadataValue<V> |
getWithMetadata(K key)
Returns the
MetadataValue associated to the supplied key param, or null if it doesn't exist. |
boolean |
isEmpty() |
Set<K> |
keySet()
Returns all keys in the remote server.
|
void |
putAll(Map<? extends K,? extends V> m)
Synthetic operation.
|
void |
putAll(Map<? extends K,? extends V> map,
long lifespan,
TimeUnit unit)
Synthetic operation.
|
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)
Synthetic operation.
|
NotifyingFuture<Void> |
putAllAsync(Map<? extends K,? extends V> data,
long lifespan,
TimeUnit unit)
Synthetic operation.
|
NotifyingFuture<Void> |
putAllAsync(Map<? extends K,? extends V> data,
long lifespan,
TimeUnit lifespanUnit,
long maxIdle,
TimeUnit maxIdleUnit)
Synthetic operation.
|
boolean |
remove(Object key,
Object value)
This operation is not supported.
|
NotifyingFuture<Boolean> |
removeAsync(Object key,
Object value)
This operation is not supported.
|
boolean |
removeWithVersion(K key,
long version)
Removes the given entry only if its version matches the supplied version.
|
NotifyingFuture<Boolean> |
removeWithVersionAsync(K key,
long version) |
boolean |
replace(K key,
V oldValue,
V newValue)
This operation is not supported.
|
boolean |
replace(K key,
V oldValue,
V value,
long lifespan,
TimeUnit unit)
This operation is not supported.
|
boolean |
replace(K key,
V oldValue,
V value,
long lifespan,
TimeUnit lifespanUnit,
long maxIdleTime,
TimeUnit maxIdleTimeUnit)
This operation is not supported.
|
NotifyingFuture<Boolean> |
replaceAsync(K key,
V oldValue,
V newValue)
This operation is not supported.
|
NotifyingFuture<Boolean> |
replaceAsync(K key,
V oldValue,
V newValue,
long lifespan,
TimeUnit unit)
This operation is not supported.
|
NotifyingFuture<Boolean> |
replaceAsync(K key,
V oldValue,
V newValue,
long lifespan,
TimeUnit lifespanUnit,
long maxIdle,
TimeUnit maxIdleUnit)
This operation is not supported.
|
boolean |
replaceWithVersion(K key,
V newValue,
long version)
Replaces the given value only if its version matches the supplied version.
|
boolean |
replaceWithVersion(K key,
V newValue,
long version,
int lifespanSeconds)
A overloaded form of
replaceWithVersion(Object, Object, long)
which takes in lifespan parameters. |
boolean |
replaceWithVersion(K key,
V newValue,
long version,
int lifespanSeconds,
int maxIdleTimeSeconds)
A overloaded form of
replaceWithVersion(Object, Object, long)
which takes in lifespan and maximum idle time parameters. |
NotifyingFuture<Boolean> |
replaceWithVersionAsync(K key,
V newValue,
long version) |
NotifyingFuture<Boolean> |
replaceWithVersionAsync(K key,
V newValue,
long version,
int lifespanSeconds) |
NotifyingFuture<Boolean> |
replaceWithVersionAsync(K key,
V newValue,
long version,
int lifespanSeconds,
int maxIdleSeconds) |
int |
size() |
ServerStatistics |
stats() |
Collection<V> |
values() |
RemoteCache<K,V> |
withFlags(Flag... flags)
Applies one or more
Flags to the scope of a single invocation. |
clearAsync, getAsync, getName, getVersion, put, put, put, putAsync, putAsync, putAsync, putIfAbsent, putIfAbsent, putIfAbsentAsync, putIfAbsentAsync, putIfAbsentAsync, remove, removeAsync, replace, replace, replaceAsync, replaceAsync, replaceAsyncputIfAbsent, replaceboolean removeWithVersion(K key, long version)
VersionedEntry ve = remoteCache.getVersioned(key); //some processing remoteCache.removeWithVersion(key, ve.getVersion();Lat call (removeWithVersion) will make sure that the entry will only be removed if it hasn't been changed in between.
VersionedValue,
getVersioned(Object)NotifyingFuture<Boolean> removeWithVersionAsync(K key, long version)
remove(Object, Object)boolean replaceWithVersion(K key, V newValue, long version)
removeWithVersion(Object, long) for a sample usage of the
version-based methods.version - numeric version that should match the one in the server
for the operation to succeedgetVersioned(Object),
VersionedValueboolean replaceWithVersion(K key, V newValue, long version, int lifespanSeconds)
replaceWithVersion(Object, Object, long)
which takes in lifespan parameters.key - key to usenewValue - new value to be associated with the keyversion - numeric version that should match the one in the server
for the operation to succeedlifespanSeconds - lifespan of the entryboolean replaceWithVersion(K key, V newValue, long version, int lifespanSeconds, int maxIdleTimeSeconds)
replaceWithVersion(Object, Object, long)
which takes in lifespan and maximum idle time parameters.key - key to usenewValue - new value to be associated with the keyversion - numeric version that should match the one in the server
for the operation to succeedlifespanSeconds - lifespan of the entrymaxIdleTimeSeconds - the maximum amount of time this key is allowed
to be idle for before it is considered as expiredNotifyingFuture<Boolean> replaceWithVersionAsync(K key, V newValue, long version)
NotifyingFuture<Boolean> replaceWithVersionAsync(K key, V newValue, long version, int lifespanSeconds)
NotifyingFuture<Boolean> replaceWithVersionAsync(K key, V newValue, long version, int lifespanSeconds, int maxIdleSeconds)
VersionedValue<V> getVersioned(K key)
VersionedValue associated to the supplied key param, or null if it doesn't exist.MetadataValue<V> getWithMetadata(K key)
MetadataValue associated to the supplied key param, or null if it doesn't exist.int size()
size in interface Map<K,V>UnsupportedOperationExceptionboolean isEmpty()
isEmpty in interface Map<K,V>UnsupportedOperationExceptionboolean containsValue(Object value)
containsValue in interface Map<K,V>UnsupportedOperationExceptionSet<K> keySet()
Collection<V> values()
values in interface Map<K,V>UnsupportedOperationExceptionSet<Map.Entry<K,V>> entrySet()
entrySet in interface Map<K,V>UnsupportedOperationExceptionboolean remove(Object key, Object value)
removeWithVersion(Object, long) instead.remove in interface ConcurrentMap<K,V>UnsupportedOperationExceptionNotifyingFuture<Boolean> removeAsync(Object key, Object value)
removeWithVersionAsync(Object, long) instead.removeAsync in interface BasicCache<K,V>key - key to removevalue - value to match onUnsupportedOperationExceptionboolean replace(K key, V oldValue, V newValue)
replaceWithVersion(Object, Object, long) instead.replace in interface ConcurrentMap<K,V>UnsupportedOperationExceptionboolean replace(K key, V oldValue, V value, long lifespan, TimeUnit unit)
replaceWithVersion(Object, Object, long, int) instead.replace in interface BasicCache<K,V>key - key to useoldValue - value to replacevalue - value to storelifespan - lifespan of the entry. Negative values are interpreted as unlimited lifespan.unit - unit of measurement for the lifespanUnsupportedOperationExceptionboolean replace(K key, V oldValue, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
replaceWithVersion(Object, Object, long, int, int) instead.replace in interface BasicCache<K,V>key - key to useoldValue - value to replacevalue - value to storelifespan - lifespan of the entry. Negative values are interpreted as unlimited lifespan.lifespanUnit - time unit for lifespanmaxIdleTime - the maximum amount of time this key is allowed to be idle for before it is considered as
expiredmaxIdleTimeUnit - time unit for max idle timeUnsupportedOperationExceptionNotifyingFuture<Boolean> replaceAsync(K key, V oldValue, V newValue)
replaceWithVersionAsync(Object, Object, long) instead.replaceAsync in interface BasicCache<K,V>key - key to removeoldValue - value to overwritenewValue - value to storeUnsupportedOperationExceptionNotifyingFuture<Boolean> replaceAsync(K key, V oldValue, V newValue, long lifespan, TimeUnit unit)
replaceWithVersion(Object, Object, long, int) instead.replaceAsync in interface BasicCache<K,V>key - key to removeoldValue - value to overwritenewValue - value to storelifespan - lifespan of entryunit - time unit for lifespanUnsupportedOperationExceptionNotifyingFuture<Boolean> replaceAsync(K key, V oldValue, V newValue, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
replaceWithVersion(Object, Object, long, int, int) instead.replaceAsync in interface BasicCache<K,V>key - key to removeoldValue - value to overwritenewValue - value to storelifespan - lifespan of entrylifespanUnit - time unit for lifespanmaxIdle - the maximum amount of time this key is allowed to be idle for before it is considered as
expiredmaxIdleUnit - time unit for max idle timeUnsupportedOperationExceptionvoid putAll(Map<? extends K,? extends V> map, long lifespan, TimeUnit unit)
putAll in interface BasicCache<K,V>map - map containing mappings to enterlifespan - lifespan of the entry. Negative values are interpreted as unlimited lifespan.unit - unit of measurement for the lifespanvoid putAll(Map<? extends K,? extends V> map, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
putAll in interface BasicCache<K,V>map - map containing mappings to enterlifespan - lifespan of the entry. Negative values are interpreted as unlimited lifespan.lifespanUnit - time unit for lifespanmaxIdleTime - the maximum amount of time this key is allowed to be idle for before it is considered as
expiredmaxIdleTimeUnit - time unit for max idle timeputAll(java.util.Map, long, java.util.concurrent.TimeUnit)NotifyingFuture<Void> putAllAsync(Map<? extends K,? extends V> data)
putAllAsync in interface BasicCache<K,V>data - to storeputAll(java.util.Map, long, java.util.concurrent.TimeUnit)NotifyingFuture<Void> putAllAsync(Map<? extends K,? extends V> data, long lifespan, TimeUnit unit)
putAllAsync in interface BasicCache<K,V>data - to storelifespan - lifespan of entryunit - time unit for lifespanputAll(java.util.Map, long, java.util.concurrent.TimeUnit)NotifyingFuture<Void> putAllAsync(Map<? extends K,? extends V> data, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
putAllAsync in interface BasicCache<K,V>data - to storelifespan - lifespan of entrylifespanUnit - time unit for lifespanmaxIdle - the maximum amount of time this key is allowed to be idle for before it is considered as
expiredmaxIdleUnit - time unit for max idle timeputAll(java.util.Map, long, java.util.concurrent.TimeUnit)void putAll(Map<? extends K,? extends V> m)
putAll in interface Map<K,V>putAll(java.util.Map, long, java.util.concurrent.TimeUnit)ServerStatistics stats()
RemoteCache<K,V> withFlags(Flag... flags)
Flags to the scope of a single invocation. See the Flag enumeration to for
information on available flags.
Sample usage:
remoteCache.withFlags(Flag.FORCE_RETURN_VALUE).put("hello", "world");
flags - RemoteCacheManager getRemoteCacheManager()
RemoteCacheManager that created this cache.Map<K,V> getBulk()
Copyright © 2017 JBoss, a division of Red Hat. All Rights Reserved.