Class RemoteCacheImpl<K,V>
- java.lang.Object
-
- org.infinispan.client.hotrod.impl.RemoteCacheSupport<K,V>
-
- org.infinispan.client.hotrod.impl.RemoteCacheImpl<K,V>
-
- All Implemented Interfaces:
ConcurrentMap<K,V>
,Map<K,V>
,RemoteCache<K,V>
,org.infinispan.commons.api.AsyncCache<K,V>
,org.infinispan.commons.api.BasicCache<K,V>
,org.infinispan.commons.api.Lifecycle
,org.infinispan.commons.api.TransactionalCache
- Direct Known Subclasses:
InvalidatedNearRemoteCache
public class RemoteCacheImpl<K,V> extends RemoteCacheSupport<K,V>
- Since:
- 4.1
- Author:
- Mircea.Markus@jboss.com
-
-
Field Summary
Fields Modifier and Type Field Description protected ClientStatistics
clientStatistics
protected org.infinispan.client.hotrod.impl.operations.OperationsFactory
operationsFactory
-
Fields inherited from class org.infinispan.client.hotrod.impl.RemoteCacheSupport
defaultLifespan, defaultMaxIdleTime
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
RemoteCacheImpl(RemoteCacheManager rcm, String name, ClientStatistics clientStatistics)
RemoteCacheImpl(RemoteCacheManager rcm, String name, org.infinispan.commons.time.TimeService timeService)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addClientListener(Object listener)
Add a client listener to receive events that happen in the remote cache.void
addClientListener(Object listener, Object[] filterFactoryParams, Object[] converterFactoryParams)
Add a client listener to receive events that happen in the remote cache.protected void
assertRemoteCacheManagerIsStarted()
void
clear()
CompletableFuture<Void>
clearAsync()
Asynchronous version ofMap.clear()
.RemoteCacheClientStatisticsMXBean
clientStatistics()
Returns client-side statistics for this cache.V
compute(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
An overloaded form ofConcurrentMap.compute(Object, BiFunction)
which takes in lifespan and maxIdleTime parameters.CompletableFuture<V>
computeAsync(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
Asynchronous version ofBasicCache.compute(Object, BiFunction, long, TimeUnit, long, TimeUnit)
.boolean
containsKey(Object key)
boolean
containsValue(Object value)
org.infinispan.commons.util.CloseableIteratorSet<Map.Entry<K,V>>
entrySet()
org.infinispan.commons.util.CloseableIteratorSet<Map.Entry<K,V>>
entrySet(org.infinispan.commons.util.IntSet segments)
This method is identical toRemoteCache.entrySet()
except that it will only return entries that map to the given segments.<T> T
execute(String taskName, Map<String,?> params)
Executes a remote script passing a set of named parameters<T> T
execute(String taskName, Map<String,?> params, Object key)
Executes a remote script passing a set of named parameters, hinting that the script should be executed on the server that is expected to store given key.V
get(Object key)
Map<K,V>
getAll(Set<? extends K> keys)
Retrieves all of the entries for the provided keys.CompletableFuture<V>
getAsync(Object key)
Asynchronous version ofMap.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.Map<K,V>
getBulk()
Bulk get operations, returns all the entries within the remote cache.Map<K,V>
getBulk(int size)
Same asRemoteCache.getBulk()
, but limits the returned set of values to the specified size.CacheTopologyInfo
getCacheTopologyInfo()
ReturnsCacheTopologyInfo
for this cache.ClientStatistics
getClientStatistics()
DataFormat
getDataFormat()
Return the currentlyDataFormat
being used.Set<Object>
getListeners()
Returns a set with all the listeners registered by this client for the given cache.String
getName()
Retrieves the name of the cacheorg.infinispan.client.hotrod.impl.operations.OperationsFactory
getOperationsFactory()
String
getProtocolVersion()
Returns the HotRod protocol version supported by this RemoteCache implementationRemoteCacheManager
getRemoteCacheManager()
Returns theRemoteCacheManager
that created this cache.String
getVersion()
Retrieves the version of InfinispanVersionedValue<V>
getVersioned(K key)
Returns theVersionedValue
associated to the supplied key param, or null if it doesn't exist.MetadataValue<V>
getWithMetadata(K key)
Returns theMetadataValue
associated to the supplied key param, or null if it doesn't exist.CompletableFuture<MetadataValue<V>>
getWithMetadataAsync(K key)
Asynchronously returns theMetadataValue
associated to the supplied key param, or null if it doesn't exist.void
init(org.infinispan.commons.marshall.Marshaller marshaller, org.infinispan.client.hotrod.impl.operations.OperationsFactory operationsFactory, int estimateKeySize, int estimateValueSize, int batchSize, ObjectName jmxParent)
boolean
isEmpty()
boolean
isObjectStorage()
org.infinispan.commons.util.CloseableIteratorSet<K>
keySet()
org.infinispan.commons.util.CloseableIteratorSet<K>
keySet(org.infinispan.commons.util.IntSet segments)
This method is identical toRemoteCache.keySet()
except that it will only return keys that map to the given segments.protected byte[]
keyToBytes(Object o)
org.infinispan.client.hotrod.impl.operations.PingOperation.PingResponse
ping()
V
put(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
An overloaded form ofBasicCache.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.CompletableFuture<Void>
putAllAsync(Map<? extends K,? extends V> map, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
Synthetic operation.CompletableFuture<V>
putAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
Asynchronous version ofBasicCache.put(Object, Object, long, TimeUnit, long, TimeUnit)
.V
putIfAbsent(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
An overloaded form ofConcurrentMap.putIfAbsent(Object, Object)
, which takes in lifespan parameters.CompletableFuture<V>
putIfAbsentAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
Asynchronous version ofBasicCache.putIfAbsent(Object, Object, long, TimeUnit, long, TimeUnit)
.V
remove(Object key)
If the return value of this operation will be ignored by the application, the user is strongly encouraged to use theFlag.IGNORE_RETURN_VALUES
flag when invoking this method in order to make it behave as efficiently as possible (i.e.boolean
remove(Object key, Object value)
CompletableFuture<V>
removeAsync(Object key)
Asynchronous version ofBasicCache.remove(Object)
.void
removeClientListener(Object listener)
Remove a previously added client listener.boolean
removeWithVersion(K key, long version)
Removes the given entry only if its version matches the supplied version.CompletableFuture<Boolean>
removeWithVersionAsync(K key, long version)
V
replace(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
An overloaded form ofConcurrentMap.replace(Object, Object)
, which takes in lifespan parameters.boolean
replace(K key, V oldValue, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
An overloaded form ofConcurrentMap.replace(Object, Object, Object)
, which takes in lifespan parameters.CompletableFuture<V>
replaceAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
Asynchronous version ofBasicCache.replace(Object, Object, long, TimeUnit, long, TimeUnit)
.boolean
replaceWithVersion(K key, V newValue, long version, int lifespanSeconds, int maxIdleTimeSeconds)
A overloaded form ofRemoteCache.replaceWithVersion(Object, Object, long)
which takes in lifespan and maximum idle time parameters.boolean
replaceWithVersion(K key, V newValue, long version, long lifespan, TimeUnit lifespanTimeUnit, long maxIdle, TimeUnit maxIdleTimeUnit)
A overloaded form ofRemoteCache.replaceWithVersion(Object, Object, long)
which takes in lifespan and maximum idle time parameters.CompletableFuture<Boolean>
replaceWithVersionAsync(K key, V newValue, long version, int lifespanSeconds, int maxIdleSeconds)
CompletableFuture<Boolean>
replaceWithVersionAsync(K key, V newValue, long version, long lifespan, TimeUnit lifespanTimeUnit, long maxIdle, TimeUnit maxIdleTimeUnit)
org.infinispan.client.hotrod.impl.operations.PingOperation.PingResponse
resolveStorage()
org.infinispan.commons.util.CloseableIterator<Map.Entry<Object,Object>>
retrieveEntries(String filterConverterFactory, int batchSize)
org.infinispan.commons.util.CloseableIterator<Map.Entry<Object,Object>>
retrieveEntries(String filterConverterFactory, Object[] filterConverterParams, Set<Integer> segments, int batchSize)
Retrieve entries from the serverorg.infinispan.commons.util.CloseableIterator<Map.Entry<Object,Object>>
retrieveEntries(String filterConverterFactory, Set<Integer> segments, int batchSize)
org.infinispan.commons.util.CloseableIterator<Map.Entry<Object,Object>>
retrieveEntriesByQuery(Query filterQuery, Set<Integer> segments, int batchSize)
Retrieve entries from the server matching a query.org.infinispan.commons.util.CloseableIterator<Map.Entry<Object,MetadataValue<Object>>>
retrieveEntriesWithMetadata(Set<Integer> segments, int batchSize)
Retrieve entries with metadata informationServerStatistics
serverStatistics()
Returns server-side statistics for this cache.protected void
set(K key, V value)
This is intentionally a non-public method meant as an integration point for bytecode manipulation.int
size()
void
start()
Invoked on component startvoid
stop()
Invoked on component stopStreamingRemoteCache<K>
streaming()
Returns a cache where values are manipulated usingInputStream
andOutputStream
org.infinispan.commons.util.CloseableIteratorCollection<V>
values()
org.infinispan.commons.util.CloseableIteratorCollection<V>
values(org.infinispan.commons.util.IntSet segments)
This method is identical toRemoteCache.values()
except that it will only return values that map to the given segments.protected byte[]
valueToBytes(Object o)
<T,U>
RemoteCache<T,U>withDataFormat(DataFormat newDataFormat)
Return a new instance ofRemoteCache
using the suppliedDataFormat
.RemoteCache<K,V>
withFlags(Flag... flags)
Applies one or moreFlag
s to the scope of a single invocation.-
Methods inherited from class org.infinispan.client.hotrod.impl.RemoteCacheSupport
compute, compute, computeAsync, computeAsync, computeIfAbsent, computeIfAbsent, computeIfAbsent, computeIfAbsentAsync, computeIfAbsentAsync, computeIfAbsentAsync, computeIfPresent, computeIfPresent, computeIfPresent, computeIfPresentAsync, computeIfPresentAsync, computeIfPresentAsync, merge, merge, merge, mergeAsync, mergeAsync, mergeAsync, put, put, putAll, putAll, putAllAsync, putAllAsync, putAsync, putAsync, putIfAbsent, putIfAbsent, putIfAbsentAsync, putIfAbsentAsync, removeAsync, replace, replace, replace, replace, replaceAll, replaceAsync, replaceAsync, replaceAsync, replaceAsync, replaceAsync, replaceWithVersion, replaceWithVersion, replaceWithVersionAsync, replaceWithVersionAsync
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.infinispan.commons.api.AsyncCache
containsKeyAsync, getAllAsync
-
Methods inherited from interface java.util.concurrent.ConcurrentMap
forEach, getOrDefault
-
Methods inherited from interface org.infinispan.client.hotrod.RemoteCache
stats
-
-
-
-
Field Detail
-
operationsFactory
protected org.infinispan.client.hotrod.impl.operations.OperationsFactory operationsFactory
-
clientStatistics
protected ClientStatistics clientStatistics
-
-
Constructor Detail
-
RemoteCacheImpl
public RemoteCacheImpl(RemoteCacheManager rcm, String name, org.infinispan.commons.time.TimeService timeService)
-
RemoteCacheImpl
protected RemoteCacheImpl(RemoteCacheManager rcm, String name, ClientStatistics clientStatistics)
-
-
Method Detail
-
init
public void init(org.infinispan.commons.marshall.Marshaller marshaller, org.infinispan.client.hotrod.impl.operations.OperationsFactory operationsFactory, int estimateKeySize, int estimateValueSize, int batchSize, ObjectName jmxParent)
-
getClientStatistics
public ClientStatistics getClientStatistics()
-
getOperationsFactory
public org.infinispan.client.hotrod.impl.operations.OperationsFactory getOperationsFactory()
-
getRemoteCacheManager
public RemoteCacheManager getRemoteCacheManager()
Description copied from interface:RemoteCache
Returns theRemoteCacheManager
that created this cache.
-
removeWithVersion
public boolean removeWithVersion(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.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.- Returns:
- true if the entry has been removed
- See Also:
VersionedValue
,RemoteCache.getVersioned(Object)
-
removeWithVersionAsync
public CompletableFuture<Boolean> removeWithVersionAsync(K key, long version)
- See Also:
RemoteCache.remove(Object, Object)
-
replaceWithVersion
public boolean replaceWithVersion(K key, V newValue, long version, int lifespanSeconds, int maxIdleTimeSeconds)
Description copied from interface:RemoteCache
A overloaded form ofRemoteCache.replaceWithVersion(Object, Object, long)
which takes in lifespan and maximum idle time parameters.- 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 expired- Returns:
- true if the value was replaced
-
replaceWithVersion
public boolean replaceWithVersion(K key, V newValue, long version, long lifespan, TimeUnit lifespanTimeUnit, long maxIdle, TimeUnit maxIdleTimeUnit)
Description copied from interface:RemoteCache
A overloaded form ofRemoteCache.replaceWithVersion(Object, Object, long)
which takes in lifespan and maximum idle time parameters.- 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 succeedlifespan
- lifespan of the entrylifespanTimeUnit
-TimeUnit
for lifespanmaxIdle
- the maximum amount of time this key is allowed to be idle for before it is considered as expiredmaxIdleTimeUnit
-TimeUnit
for maxIdle- Returns:
- true if the value was replaced
-
replaceWithVersionAsync
public CompletableFuture<Boolean> replaceWithVersionAsync(K key, V newValue, long version, int lifespanSeconds, int maxIdleSeconds)
-
replaceWithVersionAsync
public CompletableFuture<Boolean> replaceWithVersionAsync(K key, V newValue, long version, long lifespan, TimeUnit lifespanTimeUnit, long maxIdle, TimeUnit maxIdleTimeUnit)
-
retrieveEntries
public org.infinispan.commons.util.CloseableIterator<Map.Entry<Object,Object>> retrieveEntries(String filterConverterFactory, Object[] filterConverterParams, Set<Integer> segments, int batchSize)
Description copied from interface:RemoteCache
Retrieve entries from the server- Parameters:
filterConverterFactory
- Factory name for the KeyValueFilterConverter or null for no filtering.filterConverterParams
- Parameters to the KeyValueFilterConvertersegments
- The segments to iterate. If null all segments will be iterated. An empty set will filter out all entries.batchSize
- The number of entries transferred from the server at a time.- Returns:
- Iterator for the entries
-
retrieveEntries
public org.infinispan.commons.util.CloseableIterator<Map.Entry<Object,Object>> retrieveEntries(String filterConverterFactory, Set<Integer> segments, int batchSize)
-
retrieveEntries
public org.infinispan.commons.util.CloseableIterator<Map.Entry<Object,Object>> retrieveEntries(String filterConverterFactory, int batchSize)
-
retrieveEntriesByQuery
public org.infinispan.commons.util.CloseableIterator<Map.Entry<Object,Object>> retrieveEntriesByQuery(Query filterQuery, Set<Integer> segments, int batchSize)
Description copied from interface:RemoteCache
Retrieve entries from the server matching a query.- Parameters:
filterQuery
-Query
segments
- The segments to iterate. If null all segments will be iterated. An empty set will filter out all entries.batchSize
- The number of entries transferred from the server at a time.- Returns:
CloseableIterator
-
retrieveEntriesWithMetadata
public org.infinispan.commons.util.CloseableIterator<Map.Entry<Object,MetadataValue<Object>>> retrieveEntriesWithMetadata(Set<Integer> segments, int batchSize)
Description copied from interface:RemoteCache
Retrieve entries with metadata information
-
getVersioned
public VersionedValue<V> getVersioned(K key)
Description copied from interface:RemoteCache
Returns theVersionedValue
associated to the supplied key param, or null if it doesn't exist.
-
getWithMetadataAsync
public CompletableFuture<MetadataValue<V>> getWithMetadataAsync(K key)
Description copied from interface:RemoteCache
Asynchronously returns theMetadataValue
associated to the supplied key param, or null if it doesn't exist.
-
getWithMetadata
public MetadataValue<V> getWithMetadata(K key)
Description copied from interface:RemoteCache
Returns theMetadataValue
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 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 time- See Also:
RemoteCache.putAll(java.util.Map, long, java.util.concurrent.TimeUnit)
-
putAllAsync
public CompletableFuture<Void> putAllAsync(Map<? extends K,? extends V> map, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
Description copied from interface:RemoteCache
Synthetic operation.- Parameters:
map
- to storelifespan
- lifespan of entrylifespanUnit
- 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 time- Returns:
- a future containing a void return type
- See Also:
RemoteCache.putAll(java.util.Map, long, java.util.concurrent.TimeUnit)
-
size
public int size()
-
isEmpty
public boolean isEmpty()
-
clientStatistics
public RemoteCacheClientStatisticsMXBean clientStatistics()
Description copied from interface:RemoteCache
Returns client-side statistics for this cache.
-
serverStatistics
public ServerStatistics serverStatistics()
Description copied from interface:RemoteCache
Returns server-side statistics for this cache.
-
put
public V put(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
Description copied from interface:org.infinispan.commons.api.BasicCache
An overloaded form ofBasicCache.put(Object, Object)
, which takes in lifespan parameters.- Specified by:
put
in interfaceorg.infinispan.commons.api.BasicCache<K,V>
- Overrides:
put
in classRemoteCacheSupport<K,V>
- Parameters:
key
- key to usevalue
- 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 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:org.infinispan.commons.api.BasicCache
An overloaded form ofConcurrentMap.putIfAbsent(Object, Object)
, which takes in lifespan parameters.- Specified by:
putIfAbsent
in interfaceorg.infinispan.commons.api.BasicCache<K,V>
- Overrides:
putIfAbsent
in classRemoteCacheSupport<K,V>
- Parameters:
key
- key to usevalue
- 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 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:org.infinispan.commons.api.BasicCache
An overloaded form ofConcurrentMap.replace(Object, Object)
, which takes in lifespan parameters.- Specified by:
replace
in interfaceorg.infinispan.commons.api.BasicCache<K,V>
- Overrides:
replace
in classRemoteCacheSupport<K,V>
- Parameters:
key
- key to usevalue
- 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 time- Returns:
- the value being replaced, or null if nothing is being replaced.
-
replace
public boolean replace(K key, V oldValue, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
Description copied from interface:RemoteCache
An overloaded form ofConcurrentMap.replace(Object, Object, Object)
, which takes in lifespan parameters.This method requires 2 round trips to the server. The first to retrieve the value and version and a second to replace the key with the version if the value matches. If possible user should use
RemoteCache.getWithMetadata(Object)
andRemoteCache.replaceWithVersion(Object, Object, long, long, TimeUnit, long, TimeUnit)
if possible.- Specified by:
replace
in interfaceorg.infinispan.commons.api.BasicCache<K,V>
- Specified by:
replace
in interfaceRemoteCache<K,V>
- Overrides:
replace
in classRemoteCacheSupport<K,V>
- Parameters:
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 time- Returns:
- true if the value was replaced, false otherwise
-
putAsync
public CompletableFuture<V> putAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
Description copied from interface:org.infinispan.commons.api.AsyncCache
Asynchronous version ofBasicCache.put(Object, Object, long, TimeUnit, long, TimeUnit)
. This method does not block on remote calls, even if your cache mode is synchronous.- Parameters:
key
- key to usevalue
- value to storelifespan
- lifespan of entrylifespanUnit
- 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 time- Returns:
- a future containing the old value replaced
-
clearAsync
public CompletableFuture<Void> clearAsync()
Description copied from interface:org.infinispan.commons.api.AsyncCache
Asynchronous version ofMap.clear()
. This method does not block on remote calls, even if your cache mode is synchronous.- Returns:
- a future containing a void return type
-
compute
public V compute(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
Description copied from interface:org.infinispan.commons.api.BasicCache
An overloaded form ofConcurrentMap.compute(Object, BiFunction)
which takes in lifespan and maxIdleTime parameters.- Specified by:
compute
in interfaceorg.infinispan.commons.api.BasicCache<K,V>
- Overrides:
compute
in classRemoteCacheSupport<K,V>
- Parameters:
key
- key to useremappingFunction
- function to use to compute and store the value under keylifespan
- 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 time- Returns:
- the computed value that was stored under key
-
computeAsync
public CompletableFuture<V> computeAsync(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
Description copied from interface:org.infinispan.commons.api.AsyncCache
Asynchronous version ofBasicCache.compute(Object, BiFunction, long, TimeUnit, long, TimeUnit)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
computeAsync
in interfaceorg.infinispan.commons.api.AsyncCache<K,V>
- Overrides:
computeAsync
in classRemoteCacheSupport<K,V>
-
putIfAbsentAsync
public CompletableFuture<V> putIfAbsentAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
Description copied from interface:org.infinispan.commons.api.AsyncCache
Asynchronous version ofBasicCache.putIfAbsent(Object, Object, long, TimeUnit, long, TimeUnit)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
putIfAbsentAsync
in interfaceorg.infinispan.commons.api.AsyncCache<K,V>
- Overrides:
putIfAbsentAsync
in classRemoteCacheSupport<K,V>
- Parameters:
key
- key to usevalue
- value to storelifespan
- lifespan of entrylifespanUnit
- 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 time- Returns:
- a future containing the old value replaced
-
removeAsync
public CompletableFuture<V> removeAsync(Object key)
Description copied from interface:org.infinispan.commons.api.AsyncCache
Asynchronous version ofBasicCache.remove(Object)
. This method does not block on remote calls, even if your cache mode is synchronous.- Parameters:
key
- key to remove- Returns:
- a future containing the value removed
-
replaceAsync
public CompletableFuture<V> replaceAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
Description copied from interface:org.infinispan.commons.api.AsyncCache
Asynchronous version ofBasicCache.replace(Object, Object, long, TimeUnit, long, TimeUnit)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
replaceAsync
in interfaceorg.infinispan.commons.api.AsyncCache<K,V>
- Overrides:
replaceAsync
in classRemoteCacheSupport<K,V>
- Parameters:
key
- key to removevalue
- value to storelifespan
- lifespan of entrylifespanUnit
- 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 time- Returns:
- a future containing the previous value overwritten
-
containsKey
public boolean containsKey(Object key)
-
containsValue
public boolean containsValue(Object value)
-
getAll
public Map<K,V> getAll(Set<? extends K> keys)
Description copied from interface:RemoteCache
Retrieves all of the entries for the provided keys. A key will not be present in the resulting map if the entry was not found in the cache.- Parameters:
keys
- The keys to find values for- Returns:
- The entries that were present for the given keys
-
getBulk
public Map<K,V> getBulk()
Description copied from interface:RemoteCache
Bulk get operations, returns all the entries within the remote cache.- Returns:
- the returned values depend on the configuration of the back-end infinispan servers. Read this for more details. The returned Map is unmodifiable.
-
getBulk
public Map<K,V> getBulk(int size)
Description copied from interface:RemoteCache
Same asRemoteCache.getBulk()
, but limits the returned set of values to the specified size. No ordering is guaranteed, and there is no guarantee that "size" elements are returned( e.g. if the number of elements in the back-end server is smaller that "size")
-
remove
public V remove(Object key)
Description copied from interface:RemoteCache
If the return value of this operation will be ignored by the application, the user is strongly encouraged to use theFlag.IGNORE_RETURN_VALUES
flag when invoking this method in order to make it behave as efficiently as possible (i.e. avoiding needless remote or network calls).The returned value is only sent back if
Flag.FORCE_RETURN_VALUE
is enabled.
-
remove
public boolean remove(Object key, Object value)
Description copied from interface:RemoteCache
This method requires 2 round trips to the server. The first to retrieve the value and version and a second to remove the key with the version if the value matches. If possible user should use
RemoteCache.getWithMetadata(Object)
andRemoteCache.removeWithVersion(Object, long)
.
-
clear
public void clear()
-
start
public void start()
Description copied from interface:org.infinispan.commons.api.Lifecycle
Invoked on component start
-
stop
public void stop()
Description copied from interface:org.infinispan.commons.api.Lifecycle
Invoked on component stop
-
getName
public String getName()
Description copied from interface:org.infinispan.commons.api.BasicCache
Retrieves the name of the cache- Returns:
- the name of the cache
-
getVersion
public String getVersion()
Description copied from interface:org.infinispan.commons.api.BasicCache
Retrieves the version of Infinispan- Returns:
- a version string
-
getProtocolVersion
public String getProtocolVersion()
Description copied from interface:RemoteCache
Returns the HotRod protocol version supported by this RemoteCache implementation
-
addClientListener
public void addClientListener(Object listener)
Description copied from interface:RemoteCache
Add a client listener to receive events that happen in the remote cache. The listener object must be annotated with @ClientListener
annotation.
-
addClientListener
public void addClientListener(Object listener, Object[] filterFactoryParams, Object[] converterFactoryParams)
Description copied from interface:RemoteCache
Add a client listener to receive events that happen in the remote cache. The listener object must be annotated with @ClientListener annotation.
-
removeClientListener
public void removeClientListener(Object listener)
Description copied from interface:RemoteCache
Remove a previously added client listener. If the listener was not added before, this operation is a no-op.
-
getListeners
public Set<Object> getListeners()
Description copied from interface:RemoteCache
Returns a set with all the listeners registered by this client for the given cache.
-
withFlags
public RemoteCache<K,V> withFlags(Flag... flags)
Description copied from interface:RemoteCache
Applies one or moreFlag
s to the scope of a single invocation. See theFlag
enumeration to for information on available flags. Sample usage:remoteCache.withFlags(Flag.FORCE_RETURN_VALUE).put("hello", "world");
- Returns:
- the current RemoteCache instance to continue running operations on.
-
getAsync
public CompletableFuture<V> getAsync(Object key)
Description copied from interface:org.infinispan.commons.api.AsyncCache
Asynchronous version ofMap.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 stores are configured, the get asynchronous call will act sequentially and will have no different toMap.get(Object)
.- 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)
-
ping
public org.infinispan.client.hotrod.impl.operations.PingOperation.PingResponse ping()
-
keyToBytes
protected byte[] keyToBytes(Object o)
-
valueToBytes
protected byte[] valueToBytes(Object o)
-
assertRemoteCacheManagerIsStarted
protected void assertRemoteCacheManagerIsStarted()
-
set
protected void set(K key, V value)
Description copied from class:RemoteCacheSupport
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.- Specified by:
set
in classRemoteCacheSupport<K,V>
-
keySet
public org.infinispan.commons.util.CloseableIteratorSet<K> keySet()
-
keySet
public org.infinispan.commons.util.CloseableIteratorSet<K> keySet(org.infinispan.commons.util.IntSet segments)
Description copied from interface:RemoteCache
This method is identical toRemoteCache.keySet()
except that it will only return keys that map to the given segments. Note that these segments will be determined by the remote server. Thus you should be aware of how many segments it has configured and hashing algorithm it is using. If the segments and hashing algorithm are not the same this method may return unexpected keys.- Parameters:
segments
- the segments of keys to return - null means all available- Returns:
- set containing keys that map to the given segments
- See Also:
RemoteCache.keySet()
-
entrySet
public org.infinispan.commons.util.CloseableIteratorSet<Map.Entry<K,V>> entrySet(org.infinispan.commons.util.IntSet segments)
Description copied from interface:RemoteCache
This method is identical toRemoteCache.entrySet()
except that it will only return entries that map to the given segments. Note that these segments will be determined by the remote server. Thus you should be aware of how many segments it has configured and hashing algorithm it is using. If the segments and hashing algorithm are not the same this method may return unexpected entries.- Parameters:
segments
- the segments of entries to return - null means all available- Returns:
- set containing entries that map to the given segments
- See Also:
RemoteCache.entrySet()
-
values
public org.infinispan.commons.util.CloseableIteratorCollection<V> values()
-
values
public org.infinispan.commons.util.CloseableIteratorCollection<V> values(org.infinispan.commons.util.IntSet segments)
Description copied from interface:RemoteCache
This method is identical toRemoteCache.values()
except that it will only return values that map to the given segments. Note that these segments will be determined by the remote server. Thus you should be aware of how many segments it has configured and hashing algorithm it is using. If the segments and hashing algorithm are not the same this method may return unexpected values.- Parameters:
segments
- the segments of values to return - null means all available- Returns:
- collection containing values that map to the given segments
- See Also:
RemoteCache.values()
-
execute
public <T> T execute(String taskName, Map<String,?> params)
Description copied from interface:RemoteCache
Executes a remote script passing a set of named parameters
-
execute
public <T> T execute(String taskName, Map<String,?> params, Object key)
Description copied from interface:RemoteCache
Executes a remote script passing a set of named parameters, hinting that the script should be executed on the server that is expected to store given key. The key itself is not transferred to the server.
-
getCacheTopologyInfo
public CacheTopologyInfo getCacheTopologyInfo()
Description copied from interface:RemoteCache
ReturnsCacheTopologyInfo
for this cache.
-
streaming
public StreamingRemoteCache<K> streaming()
Description copied from interface:RemoteCache
Returns a cache where values are manipulated usingInputStream
andOutputStream
-
withDataFormat
public <T,U> RemoteCache<T,U> withDataFormat(DataFormat newDataFormat)
Description copied from interface:RemoteCache
Return a new instance ofRemoteCache
using the suppliedDataFormat
.
-
resolveStorage
public org.infinispan.client.hotrod.impl.operations.PingOperation.PingResponse resolveStorage()
-
getDataFormat
public DataFormat getDataFormat()
Description copied from interface:RemoteCache
Return the currentlyDataFormat
being used.
-
isObjectStorage
public boolean isObjectStorage()
-
-