|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface RemoteCache<K,V>
Provides remote reference to a Hot Rod server/cluster. It implements 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 Flag
s: it is possible to change de default cache behaviour by using
flags on an per invocation basis.
E.g.
RemoteCache cache = getRemoteCache(); Object value = cache.withFlags(Flag.FORCE_RETURN_VALUE).get(aKey);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.
Another fundamental difference is in the case of lifespan (naturally does NOT apply for max idle): If number of seconds is bigger than 30 days,
this number of seconds is treated as UNIX time and so, represents the number of seconds since 1/1/1970.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface java.util.Map |
---|
Map.Entry<K,V> |
Method Summary | |
---|---|
void |
addListener(Object listener)
Operation might be supported for smart clients that will be able to register for topology changes. |
void |
compact()
This operation is not supported. |
boolean |
containsValue(Object value)
|
void |
endBatch(boolean successful)
Completes a batch if one has been started using Cache.startBatch() . |
Set<Map.Entry<K,V>> |
entrySet()
Returns a set view of the mappings contained in this cache. |
void |
evict(K key)
Evicts an entry from the memory of the cache. |
AdvancedCache<K,V> |
getAdvancedCache()
This operation is not supported. |
Configuration |
getConfiguration()
|
Set<Object> |
getListeners()
|
RemoteCacheManager |
getRemoteCacheManager()
Returns the RemoteCacheManager that created this cache. |
VersionedValue |
getVersioned(K key)
Returns the VersionedValue associated to the supplied key param, or null if it doesn't exist. |
boolean |
isEmpty()
|
Set<K> |
keySet()
Returns a set view of the keys contained in this cache. |
boolean |
ping()
Returns true if the remote cluster can be reached, false otherwise. |
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. |
void |
putForExternalRead(K key,
V value)
This operation is not supported. |
boolean |
remove(Object key,
Object value)
This operation is not supported. |
NotifyingFuture<Boolean> |
removeAsync(Object key,
Object value)
This operation is not supported. |
void |
removeListener(Object listener)
Removes a listener from the component. |
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)
Removes the given value only if its version matches the supplied version. |
boolean |
replaceWithVersion(K key,
V newValue,
long version,
int lifespanSeconds)
|
boolean |
replaceWithVersion(K key,
V newValue,
long version,
int lifespanSeconds,
int maxIdleTimeSeconds)
|
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()
|
boolean |
startBatch()
Starts a batch. |
ServerStatistics |
stats()
|
Collection<V> |
values()
Returns a collection view of the values contained in this cache. |
RemoteCache<K,V> |
withFlags(Flag... flags)
|
Methods inherited from interface org.infinispan.Cache |
---|
clearAsync, getCacheManager, getName, getStatus, getVersion, put, put, putAsync, putAsync, putAsync, putIfAbsent, putIfAbsent, putIfAbsentAsync, putIfAbsentAsync, putIfAbsentAsync, removeAsync, replace, replace, replaceAsync, replaceAsync, replaceAsync |
Methods inherited from interface java.util.concurrent.ConcurrentMap |
---|
putIfAbsent, replace |
Methods inherited from interface java.util.Map |
---|
clear, containsKey, equals, get, hashCode, put, remove |
Methods inherited from interface org.infinispan.lifecycle.Lifecycle |
---|
start, stop |
Method Detail |
---|
boolean 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.
getVersioned(Object)
,
VersionedValue
boolean replaceWithVersion(K key, V newValue, long version, int lifespanSeconds)
replaceWithVersion(Object, Object, long)
boolean replaceWithVersion(K key, V newValue, long version, int lifespanSeconds, int maxIdleTimeSeconds)
replaceWithVersion(Object, Object, long)
NotifyingFuture<Boolean> replaceWithVersionAsync(K key, V newValue, long version)
replaceWithVersion(Object, Object, long)
NotifyingFuture<Boolean> replaceWithVersionAsync(K key, V newValue, long version, int lifespanSeconds)
replaceWithVersion(Object, Object, long)
NotifyingFuture<Boolean> replaceWithVersionAsync(K key, V newValue, long version, int lifespanSeconds, int maxIdleSeconds)
replaceWithVersion(Object, Object, long)
VersionedValue getVersioned(K key)
VersionedValue
associated to the supplied key param, or null if it doesn't exist.
void addListener(Object listener)
addListener
in interface Listenable
listener
- must not be null.
UnsupportedOperationException
void removeListener(Object listener)
Listenable
removeListener
in interface Listenable
listener
- listener to remove. Must not be null.
UnsupportedOperationException
addListener(Object)
Set<Object> getListeners()
getListeners
in interface Listenable
UnsupportedOperationException
addListener(Object)
int size()
size
in interface Map<K,V>
UnsupportedOperationException
boolean isEmpty()
isEmpty
in interface Map<K,V>
UnsupportedOperationException
boolean containsValue(Object value)
containsValue
in interface Map<K,V>
UnsupportedOperationException
Set<K> keySet()
Cache
keySet
in interface Cache<K,V>
keySet
in interface Map<K,V>
UnsupportedOperationException
Collection<V> values()
Cache
values
in interface Cache<K,V>
values
in interface Map<K,V>
UnsupportedOperationException
Set<Map.Entry<K,V>> entrySet()
Cache
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.
entrySet
in interface Cache<K,V>
entrySet
in interface Map<K,V>
UnsupportedOperationException
void evict(K key)
Cache
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.
evict
in interface Cache<K,V>
key
- key to evict
UnsupportedOperationException
Configuration getConfiguration()
getConfiguration
in interface Cache<K,V>
UnsupportedOperationException
boolean startBatch()
Cache
startBatch
in interface Cache<K,V>
UnsupportedOperationException
void endBatch(boolean successful)
Cache
Cache.startBatch()
. If no batch has been started, this is a
no-op.
endBatch
in interface Cache<K,V>
successful
- if true, the batch completes, otherwise the batch is aborted and changes are not committed.
UnsupportedOperationException
boolean remove(Object key, Object value)
removeWithVersion(Object, long)
instead.
remove
in interface ConcurrentMap<K,V>
UnsupportedOperationException
NotifyingFuture<Boolean> removeAsync(Object key, Object value)
removeWithVersionAsync(Object, long)
instead.
removeAsync
in interface Cache<K,V>
key
- key to removevalue
- value to match on
UnsupportedOperationException
boolean replace(K key, V oldValue, V newValue)
replaceWithVersion(Object, Object, long)
instead.
replace
in interface ConcurrentMap<K,V>
UnsupportedOperationException
boolean replace(K key, V oldValue, V value, long lifespan, TimeUnit unit)
#replace(K,V,long,int)
instead.
replace
in interface Cache<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 lifespan
UnsupportedOperationException
boolean replace(K key, V oldValue, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
#replace(K,V,long,int,int)
instead.
replace
in interface Cache<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 time
UnsupportedOperationException
NotifyingFuture<Boolean> replaceAsync(K key, V oldValue, V newValue)
replaceWithVersionAsync(Object, Object, long)
instead.
replaceAsync
in interface Cache<K,V>
key
- key to removeoldValue
- value to overwritenewValue
- value to store
UnsupportedOperationException
NotifyingFuture<Boolean> replaceAsync(K key, V oldValue, V newValue, long lifespan, TimeUnit unit)
#replaceAsync(K,V,long,int)
instead.
replaceAsync
in interface Cache<K,V>
key
- key to removeoldValue
- value to overwritenewValue
- value to storelifespan
- lifespan of entryunit
- time unit for lifespan
UnsupportedOperationException
NotifyingFuture<Boolean> replaceAsync(K key, V oldValue, V newValue, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
#replaceAsync(K,V,long,int,int)
instead.
replaceAsync
in interface Cache<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 time
UnsupportedOperationException
AdvancedCache<K,V> getAdvancedCache()
getAdvancedCache
in interface Cache<K,V>
UnsupportedOperationException
void compact()
compact
in interface Cache<K,V>
UnsupportedOperationException
void putForExternalRead(K key, V value)
putForExternalRead
in interface Cache<K,V>
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.
UnsupportedOperationException
void putAll(Map<? extends K,? extends V> map, long lifespan, TimeUnit unit)
putAll
in interface Cache<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 Cache<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 Cache<K,V>
data
- to store
putAll(java.util.Map, long, java.util.concurrent.TimeUnit)
NotifyingFuture<Void> putAllAsync(Map<? extends K,? extends V> data, long lifespan, TimeUnit unit)
putAllAsync
in interface Cache<K,V>
data
- to storelifespan
- lifespan of entryunit
- time unit for lifespan
putAll(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 Cache<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 time
putAll(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)
boolean ping()
ServerStatistics stats()
RemoteCache<K,V> withFlags(Flag... flags)
RemoteCacheManager getRemoteCacheManager()
RemoteCacheManager
that created this cache.
|
Google Analytics | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |