Class RedissonMap<K,V>
- java.lang.Object
-
- org.redisson.RedissonObject
-
- org.redisson.RedissonMap<K,V>
-
- Type Parameters:
K
- keyV
- value
- All Implemented Interfaces:
ConcurrentMap<K,V>
,Map<K,V>
,RExpirable
,RExpirableAsync
,RMap<K,V>
,RMapAsync<K,V>
,RObject
,RObjectAsync
- Direct Known Subclasses:
RedissonLocalCachedMap
,RedissonMapCache
,RedissonTransactionalMap
public class RedissonMap<K,V> extends RedissonObject implements RMap<K,V>
Distributed and concurrent implementation ofConcurrentMap
andMap
- Author:
- Nikita Koksharov
-
-
Field Summary
-
Fields inherited from class org.redisson.RedissonObject
codec, commandExecutor
-
-
Constructor Summary
Constructors Constructor Description RedissonMap(Codec codec, CommandAsyncExecutor commandExecutor, String name, RedissonClient redisson, MapOptions<K,V> options)
RedissonMap(CommandAsyncExecutor commandExecutor, String name, RedissonClient redisson, MapOptions<K,V> options)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description V
addAndGet(K key, Number value)
Atomically adds the givendelta
to the current value by mappedkey
.RFuture<V>
addAndGetAsync(K key, Number value)
Atomically adds the givendelta
to the current value by mappedkey
.protected RFuture<V>
addAndGetOperationAsync(K key, Number value)
protected void
checkKey(Object key)
protected void
checkValue(Object value)
void
clear()
boolean
clearExpire()
Clear an expire timeout or expire date for object.RFuture<Boolean>
clearExpireAsync()
Clear an expire timeout or expire date for object in async mode.boolean
containsKey(Object key)
RFuture<Boolean>
containsKeyAsync(Object key)
boolean
containsValue(Object value)
RFuture<Boolean>
containsValueAsync(Object value)
protected Iterator<Map.Entry<K,V>>
entryIterator(String pattern, int count)
Set<Map.Entry<K,V>>
entrySet()
Returns map entries collection.Set<Map.Entry<K,V>>
entrySet(int count)
Returns map entries collection.Set<Map.Entry<K,V>>
entrySet(String keyPattern)
Returns map entries collection.Set<Map.Entry<K,V>>
entrySet(String keyPattern, int count)
Returns map entries collection.boolean
equals(Object o)
boolean
expire(long timeToLive, TimeUnit timeUnit)
Set a timeout for object.RFuture<Boolean>
expireAsync(long timeToLive, TimeUnit timeUnit)
Set a timeout for object in async mode.boolean
expireAt(long timestamp)
Set an expire date for object.boolean
expireAt(Date timestamp)
Set an expire date for object.RFuture<Boolean>
expireAtAsync(long timestamp)
Set an expire date for object in async mode.RFuture<Boolean>
expireAtAsync(Date timestamp)
Set an expire date for object in async mode.boolean
fastPut(K key, V value)
Associates the specifiedvalue
with the specifiedkey
.RFuture<Boolean>
fastPutAsync(K key, V value)
Associates the specifiedvalue
with the specifiedkey
in async manner.boolean
fastPutIfAbsent(K key, V value)
Associates the specifiedvalue
with the specifiedkey
only if there is no any association with specifiedkey
.RFuture<Boolean>
fastPutIfAbsentAsync(K key, V value)
Associates the specifiedvalue
with the specifiedkey
only if there is no any association with specifiedkey
.protected RFuture<Boolean>
fastPutIfAbsentOperationAsync(K key, V value)
protected RFuture<Boolean>
fastPutOperationAsync(K key, V value)
long
fastRemove(K... keys)
Removeskeys
from map by one operationRFuture<Long>
fastRemoveAsync(K... keys)
Removeskeys
from map by one operation in async manner.protected RFuture<Long>
fastRemoveOperationAsync(K... keys)
protected RFuture<List<Long>>
fastRemoveOperationBatchAsync(K... keys)
boolean
fastReplace(K key, V value)
Replaces previous value with a newvalue
associated with thekey
.RFuture<Boolean>
fastReplaceAsync(K key, V value)
Replaces previous value with a newvalue
associated with thekey
.protected RFuture<Boolean>
fastReplaceOperationAsync(K key, V value)
V
get(Object key)
Returns the value to which the specified key is mapped, ornull
if this map contains no mapping for the key.Map<K,V>
getAll(Set<K> keys)
Gets a map slice contained the mappings with definedkeys
by one operation.RFuture<Map<K,V>>
getAllAsync(Set<K> keys)
Gets a map slice contained the mappings with definedkeys
by one operation.RFuture<Map<K,V>>
getAllOperationAsync(Set<K> keys)
RFuture<V>
getAsync(K key)
Returns the value to which the specified key is mapped, ornull
if this map contains no mapping for the key.RLock
getLock(K key)
ReturnsRLock
instance associated with keyString
getLockName(Object key, String suffix)
RFuture<V>
getOperationAsync(K key)
RReadWriteLock
getReadWriteLock(K key)
ReturnsRReadWriteLock
instance associated with keyint
hashCode()
protected boolean
hasNoLoader()
protected boolean
hasNoWriter()
boolean
isEmpty()
protected Iterator<K>
keyIterator(String pattern, int count)
Set<K>
keySet()
Returns key set of this map.Set<K>
keySet(int count)
Returns key set of this map.Set<K>
keySet(String pattern)
Returns key set of this map.Set<K>
keySet(String pattern, int count)
Returns key set of this map.void
loadAll(boolean replaceExistingValues, int parallelism)
Loads all map entries to this Redis map usingMapLoader
.void
loadAll(Set<? extends K> keys, boolean replaceExistingValues, int parallelism)
Loads map entries usingMapLoader
whose keys are listed in definedkeys
parameter.RFuture<Void>
loadAllAsync(boolean replaceExistingValues, int parallelism)
Loads all map entries to this Redis map usingMapLoader
.RFuture<Void>
loadAllAsync(Set<? extends K> keys, boolean replaceExistingValues, int parallelism)
Loads map entries usingMapLoader
whose keys are listed in definedkeys
parameter.<KOut,VOut>
RMapReduce<K,V,KOut,VOut>mapReduce()
ReturnsRMapReduce
object associated with this mapprotected <M> RFuture<M>
mapWriterFuture(RFuture<M> future, MapWriterTask<M> listener)
V
put(K key, V value)
Associates the specifiedvalue
with the specifiedkey
in async manner.void
putAll(Map<? extends K,? extends V> map)
Associates the specifiedvalue
with the specifiedkey
in batch.void
putAll(Map<? extends K,? extends V> map, int batchSize)
Associates the specifiedvalue
with the specifiedkey
in batch.RFuture<Void>
putAllAsync(Map<? extends K,? extends V> map)
Associates the specifiedvalue
with the specifiedkey
in batch.RFuture<Void>
putAllAsync(Map<? extends K,? extends V> map, int batchSize)
Associates the specifiedvalue
with the specifiedkey
in batch.protected RFuture<Void>
putAllOperationAsync(Map<? extends K,? extends V> map)
RFuture<V>
putAsync(K key, V value)
Associates the specifiedvalue
with the specifiedkey
in async manner.V
putIfAbsent(K key, V value)
Associates the specifiedvalue
with the specifiedkey
only if there is no any association with specifiedkey
.RFuture<V>
putIfAbsentAsync(K key, V value)
Associates the specifiedvalue
with the specifiedkey
only if there is no any association with specifiedkey
.protected RFuture<V>
putIfAbsentOperationAsync(K key, V value)
protected RFuture<V>
putOperationAsync(K key, V value)
Set<Map.Entry<K,V>>
readAllEntrySet()
Read all map entries at onceRFuture<Set<Map.Entry<K,V>>>
readAllEntrySetAsync()
Read all map entries at onceSet<K>
readAllKeySet()
Read all keys at onceRFuture<Set<K>>
readAllKeySetAsync()
Read all keys at onceMap<K,V>
readAllMap()
Read all map as local instance at onceRFuture<Map<K,V>>
readAllMapAsync()
Read all map as local instance at onceCollection<V>
readAllValues()
Read all values at onceRFuture<Collection<V>>
readAllValuesAsync()
Read all values at oncelong
remainTimeToLive()
Remaining time to live of Redisson object that has a timeoutRFuture<Long>
remainTimeToLiveAsync()
Remaining time to live of Redisson object that has a timeoutV
remove(Object key)
Removeskey
from map and returns associated value in async manner.boolean
remove(Object key, Object value)
Removeskey
from map only if it associated withvalue
.RFuture<Boolean>
removeAsync(Object key, Object value)
Removeskey
from map only if it associated withvalue
.RFuture<V>
removeAsync(K key)
Removeskey
from map and returns associated value in async manner.protected RFuture<Boolean>
removeOperationAsync(Object key, Object value)
protected RFuture<V>
removeOperationAsync(K key)
V
replace(K key, V value)
Replaces previous value with a newvalue
associated with thekey
.boolean
replace(K key, V oldValue, V newValue)
Replaces previousoldValue
with anewValue
associated with thekey
.RFuture<V>
replaceAsync(K key, V value)
Replaces previous value with a newvalue
associated with thekey
.RFuture<Boolean>
replaceAsync(K key, V oldValue, V newValue)
Replaces previousoldValue
with anewValue
associated with thekey
.protected RFuture<V>
replaceOperationAsync(K key, V value)
protected RFuture<Boolean>
replaceOperationAsync(K key, V oldValue, V newValue)
MapScanResult<Object,Object>
scanIterator(String name, RedisClient client, long startPos, String pattern, int count)
RFuture<MapScanResult<Object,Object>>
scanIteratorAsync(String name, RedisClient client, long startPos, String pattern, int count)
int
size()
RFuture<Integer>
sizeAsync()
Returns size of this mapprotected Iterator<V>
valueIterator(String pattern, int count)
Collection<V>
values()
Returns values collection of this map.Collection<V>
values(int count)
Returns values collection of this map.Collection<V>
values(String keyPattern)
Returns values collection of this map.Collection<V>
values(String keyPattern, int count)
Returns values collection of this map.int
valueSize(K key)
Returns size of value mapped by key in bytesRFuture<Integer>
valueSizeAsync(K key)
Returns size of value mapped by key in bytes-
Methods inherited from class org.redisson.RedissonObject
await, copy, copyAsync, delete, deleteAsync, dump, dumpAsync, encode, encode, encode, encodeMapKey, encodeMapKeys, encodeMapValue, encodeMapValues, get, getCodec, getName, getName, isExists, isExistsAsync, migrate, migrateAsync, move, moveAsync, prefixName, rename, renameAsync, renamenx, renamenxAsync, restore, restore, restoreAndReplace, restoreAndReplace, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, suffixName, toSeconds, touch, touchAsync, unlink, unlinkAsync
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.concurrent.ConcurrentMap
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, replaceAll
-
Methods inherited from interface org.redisson.api.RExpirable
clearExpire, expire, expireAt, expireAt, remainTimeToLive
-
Methods inherited from interface org.redisson.api.RExpirableAsync
clearExpireAsync, expireAsync, expireAtAsync, expireAtAsync, remainTimeToLiveAsync
-
Methods inherited from interface org.redisson.api.RObject
copy, delete, dump, getCodec, getName, isExists, migrate, move, rename, renamenx, restore, restore, restoreAndReplace, restoreAndReplace, touch, unlink
-
Methods inherited from interface org.redisson.api.RObjectAsync
copyAsync, deleteAsync, dumpAsync, isExistsAsync, migrateAsync, moveAsync, renameAsync, renamenxAsync, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, touchAsync, unlinkAsync
-
-
-
-
Constructor Detail
-
RedissonMap
public RedissonMap(CommandAsyncExecutor commandExecutor, String name, RedissonClient redisson, MapOptions<K,V> options)
-
RedissonMap
public RedissonMap(Codec codec, CommandAsyncExecutor commandExecutor, String name, RedissonClient redisson, MapOptions<K,V> options)
-
-
Method Detail
-
mapReduce
public <KOut,VOut> RMapReduce<K,V,KOut,VOut> mapReduce()
Description copied from interface:RMap
ReturnsRMapReduce
object associated with this map
-
getLock
public RLock getLock(K key)
Description copied from interface:RMap
ReturnsRLock
instance associated with key
-
getReadWriteLock
public RReadWriteLock getReadWriteLock(K key)
Description copied from interface:RMap
ReturnsRReadWriteLock
instance associated with key- Specified by:
getReadWriteLock
in interfaceRMap<K,V>
- Parameters:
key
- - map key- Returns:
- readWriteLock
-
sizeAsync
public RFuture<Integer> sizeAsync()
Description copied from interface:RMapAsync
Returns size of this map
-
valueSize
public int valueSize(K key)
Description copied from interface:RMap
Returns size of value mapped by key in bytes
-
valueSizeAsync
public RFuture<Integer> valueSizeAsync(K key)
Description copied from interface:RMapAsync
Returns size of value mapped by key in bytes- Specified by:
valueSizeAsync
in interfaceRMapAsync<K,V>
- Parameters:
key
- - map key- Returns:
- size of value
-
checkKey
protected void checkKey(Object key)
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKey
in interfaceMap<K,V>
-
containsKeyAsync
public RFuture<Boolean> containsKeyAsync(Object key)
- Specified by:
containsKeyAsync
in interfaceRMapAsync<K,V>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValue
in interfaceMap<K,V>
-
containsValueAsync
public RFuture<Boolean> containsValueAsync(Object value)
- Specified by:
containsValueAsync
in interfaceRMapAsync<K,V>
-
getAll
public Map<K,V> getAll(Set<K> keys)
Description copied from interface:RMap
Gets a map slice contained the mappings with definedkeys
by one operation.If map doesn't contain value/values for specified key/keys and
MapLoader
is defined then value/values will be loaded in read-through mode.The returned map is NOT backed by the original map.
-
getAllAsync
public RFuture<Map<K,V>> getAllAsync(Set<K> keys)
Description copied from interface:RMapAsync
Gets a map slice contained the mappings with definedkeys
by one operation.If map doesn't contain value/values for specified key/keys and
MapLoader
is defined then value/values will be loaded in read-through mode.The returned map is NOT backed by the original map.
- Specified by:
getAllAsync
in interfaceRMapAsync<K,V>
- Parameters:
keys
- - map keys- Returns:
- Map slice
-
hasNoLoader
protected boolean hasNoLoader()
-
get
public V get(Object key)
Description copied from interface:RMap
Returns the value to which the specified key is mapped, ornull
if this map contains no mapping for the key.If map doesn't contain value for specified key and
MapLoader
is defined then value will be loaded in read-through mode.
-
put
public V put(K key, V value)
Description copied from interface:RMap
Associates the specifiedvalue
with the specifiedkey
in async manner.If
MapWriter
is defined then new map entry is stored in write-through mode.
-
remove
public V remove(Object key)
Description copied from interface:RMap
Removeskey
from map and returns associated value in async manner.If
MapWriter
is defined thenkey
is deleted in write-through mode.
-
putAll
public final void putAll(Map<? extends K,? extends V> map)
Description copied from interface:RMap
Associates the specifiedvalue
with the specifiedkey
in batch.If
MapWriter
is defined then new map entries will be stored in write-through mode.
-
putAll
public void putAll(Map<? extends K,? extends V> map, int batchSize)
Description copied from interface:RMap
Associates the specifiedvalue
with the specifiedkey
in batch. Batch inserted by chunks limited bybatchSize
amount to avoid OOM and/or Redis response timeout error for map with big size.If
MapWriter
is defined then new map entries are stored in write-through mode.
-
putAllAsync
public RFuture<Void> putAllAsync(Map<? extends K,? extends V> map, int batchSize)
Description copied from interface:RMapAsync
Associates the specifiedvalue
with the specifiedkey
in batch. Batch inserted by chunks limited bybatchSize
amount to avoid OOM and/or Redis response timeout error for map with big size.If
MapWriter
is defined then new map entries are stored in write-through mode.- Specified by:
putAllAsync
in interfaceRMapAsync<K,V>
- Parameters:
map
- mappings to be stored in this mapbatchSize
- - map chunk size- Returns:
- void
-
putAllAsync
public final RFuture<Void> putAllAsync(Map<? extends K,? extends V> map)
Description copied from interface:RMapAsync
Associates the specifiedvalue
with the specifiedkey
in batch.If
MapWriter
is defined then new map entries are stored in write-through mode.- Specified by:
putAllAsync
in interfaceRMapAsync<K,V>
- Parameters:
map
- mappings to be stored in this map- Returns:
- void
-
mapWriterFuture
protected final <M> RFuture<M> mapWriterFuture(RFuture<M> future, MapWriterTask<M> listener)
-
putAllOperationAsync
protected RFuture<Void> putAllOperationAsync(Map<? extends K,? extends V> map)
-
keySet
public Set<K> keySet()
Description copied from interface:RMap
Returns key set of this map. Keys are loaded in batch. Batch size is10
.
-
keySet
public Set<K> keySet(String pattern)
Description copied from interface:RMap
Returns key set of this map. Ifpattern
is not null then only keys match this pattern are loaded. Supported glob-style patterns:h?llo subscribes to hello, hallo and hxllo
h*llo subscribes to hllo and heeeello
h[ae]llo subscribes to hello and hallo, but not hillo
- Specified by:
keySet
in interfaceRMap<K,V>
- Parameters:
pattern
- - key pattern- Returns:
- key set
- See Also:
RMap.readAllKeySet()
-
keySet
public Set<K> keySet(String pattern, int count)
Description copied from interface:RMap
Returns key set of this map. Ifpattern
is not null then only keys match this pattern are loaded. Keys are loaded in batch. Batch size is defined bycount
param. Supported glob-style patterns:h?llo subscribes to hello, hallo and hxllo
h*llo subscribes to hllo and heeeello
h[ae]llo subscribes to hello and hallo, but not hillo
- Specified by:
keySet
in interfaceRMap<K,V>
- Parameters:
pattern
- - key patterncount
- - size of keys batch- Returns:
- key set
- See Also:
RMap.readAllKeySet()
-
keySet
public Set<K> keySet(int count)
Description copied from interface:RMap
Returns key set of this map. Keys are loaded in batch. Batch size is defined bycount
param.- Specified by:
keySet
in interfaceRMap<K,V>
- Parameters:
count
- - size of keys batch- Returns:
- key set
- See Also:
RMap.readAllKeySet()
-
values
public Collection<V> values()
Description copied from interface:RMap
Returns values collection of this map. Values are loaded in batch. Batch size is10
.
-
values
public Collection<V> values(String keyPattern, int count)
Description copied from interface:RMap
Returns values collection of this map. Values are loaded in batch. Batch size is defined bycount
param. IfkeyPattern
is not null then only values mapped by matched keys of this pattern are loaded. Supported glob-style patterns:h?llo subscribes to hello, hallo and hxllo
h*llo subscribes to hllo and heeeello
h[ae]llo subscribes to hello and hallo, but not hillo
- Specified by:
values
in interfaceRMap<K,V>
- Parameters:
keyPattern
- - key patterncount
- - size of values batch- Returns:
- values collection
- See Also:
RMap.readAllValues()
-
values
public Collection<V> values(String keyPattern)
Description copied from interface:RMap
Returns values collection of this map. Values are loaded in batch. Batch size is10
. IfkeyPattern
is not null then only values mapped by matched keys of this pattern are loaded. Supported glob-style patterns:h?llo subscribes to hello, hallo and hxllo
h*llo subscribes to hllo and heeeello
h[ae]llo subscribes to hello and hallo, but not hillo
- Specified by:
values
in interfaceRMap<K,V>
- Parameters:
keyPattern
- - key pattern- Returns:
- values collection
- See Also:
RMap.readAllValues()
-
values
public Collection<V> values(int count)
Description copied from interface:RMap
Returns values collection of this map. Values are loaded in batch. Batch size is defined bycount
param.- Specified by:
values
in interfaceRMap<K,V>
- Parameters:
count
- - size of values batch- Returns:
- values collection
- See Also:
RMap.readAllValues()
-
entrySet
public Set<Map.Entry<K,V>> entrySet()
Description copied from interface:RMap
Returns map entries collection. Map entries are loaded in batch. Batch size is10
.
-
entrySet
public Set<Map.Entry<K,V>> entrySet(String keyPattern)
Description copied from interface:RMap
Returns map entries collection. Map entries are loaded in batch. Batch size is10
. IfkeyPattern
is not null then only entries mapped by matched keys of this pattern are loaded. Supported glob-style patterns:h?llo subscribes to hello, hallo and hxllo
h*llo subscribes to hllo and heeeello
h[ae]llo subscribes to hello and hallo, but not hillo
- Specified by:
entrySet
in interfaceRMap<K,V>
- Parameters:
keyPattern
- - key pattern- Returns:
- map entries collection
- See Also:
RMap.readAllEntrySet()
-
entrySet
public Set<Map.Entry<K,V>> entrySet(String keyPattern, int count)
Description copied from interface:RMap
Returns map entries collection. Map entries are loaded in batch. Batch size is defined bycount
param. IfkeyPattern
is not null then only entries mapped by matched keys of this pattern are loaded. Supported glob-style patterns:h?llo subscribes to hello, hallo and hxllo
h*llo subscribes to hllo and heeeello
h[ae]llo subscribes to hello and hallo, but not hillo
- Specified by:
entrySet
in interfaceRMap<K,V>
- Parameters:
keyPattern
- - key patterncount
- - size of entries batch- Returns:
- map entries collection
- See Also:
RMap.readAllEntrySet()
-
entrySet
public Set<Map.Entry<K,V>> entrySet(int count)
Description copied from interface:RMap
Returns map entries collection. Map entries are loaded in batch. Batch size is defined bycount
param.- Specified by:
entrySet
in interfaceRMap<K,V>
- Parameters:
count
- - size of entries batch- Returns:
- map entries collection
- See Also:
RMap.readAllEntrySet()
-
readAllKeySet
public Set<K> readAllKeySet()
Description copied from interface:RMap
Read all keys at once- Specified by:
readAllKeySet
in interfaceRMap<K,V>
- Returns:
- keys
-
readAllKeySetAsync
public RFuture<Set<K>> readAllKeySetAsync()
Description copied from interface:RMapAsync
Read all keys at once- Specified by:
readAllKeySetAsync
in interfaceRMapAsync<K,V>
- Returns:
- keys
-
readAllValues
public Collection<V> readAllValues()
Description copied from interface:RMap
Read all values at once- Specified by:
readAllValues
in interfaceRMap<K,V>
- Returns:
- values
-
readAllValuesAsync
public RFuture<Collection<V>> readAllValuesAsync()
Description copied from interface:RMapAsync
Read all values at once- Specified by:
readAllValuesAsync
in interfaceRMapAsync<K,V>
- Returns:
- values
-
readAllEntrySet
public Set<Map.Entry<K,V>> readAllEntrySet()
Description copied from interface:RMap
Read all map entries at once- Specified by:
readAllEntrySet
in interfaceRMap<K,V>
- Returns:
- entries
-
readAllEntrySetAsync
public RFuture<Set<Map.Entry<K,V>>> readAllEntrySetAsync()
Description copied from interface:RMapAsync
Read all map entries at once- Specified by:
readAllEntrySetAsync
in interfaceRMapAsync<K,V>
- Returns:
- entries
-
readAllMap
public Map<K,V> readAllMap()
Description copied from interface:RMap
Read all map as local instance at once- Specified by:
readAllMap
in interfaceRMap<K,V>
- Returns:
- map
-
readAllMapAsync
public RFuture<Map<K,V>> readAllMapAsync()
Description copied from interface:RMapAsync
Read all map as local instance at once- Specified by:
readAllMapAsync
in interfaceRMapAsync<K,V>
- Returns:
- map
-
putIfAbsent
public V putIfAbsent(K key, V value)
Description copied from interface:RMap
Associates the specifiedvalue
with the specifiedkey
only if there is no any association with specifiedkey
.If
MapWriter
is defined then new map entry is stored in write-through mode.- Specified by:
putIfAbsent
in interfaceConcurrentMap<K,V>
- Specified by:
putIfAbsent
in interfaceMap<K,V>
- Specified by:
putIfAbsent
in interfaceRMap<K,V>
- Parameters:
key
- - map keyvalue
- - map value- Returns:
null
if key is a new one in the hash and value was set. Previous value if key already exists in the hash and change hasn't been made.
-
putIfAbsentAsync
public RFuture<V> putIfAbsentAsync(K key, V value)
Description copied from interface:RMapAsync
Associates the specifiedvalue
with the specifiedkey
only if there is no any association with specifiedkey
.If
MapWriter
is defined then new map entry is stored in write-through mode.- Specified by:
putIfAbsentAsync
in interfaceRMapAsync<K,V>
- Parameters:
key
- - map keyvalue
- - map value- Returns:
null
if key is a new one in the hash and value was set. Previous value if key already exists in the hash and change hasn't been made.
-
hasNoWriter
protected boolean hasNoWriter()
-
fastPutIfAbsent
public boolean fastPutIfAbsent(K key, V value)
Description copied from interface:RMap
Associates the specifiedvalue
with the specifiedkey
only if there is no any association with specifiedkey
.Works faster than
but not returning the previous value associated withRMap.putIfAbsent(Object, Object)
key
If
MapWriter
is defined then new map entry is stored in write-through mode.- Specified by:
fastPutIfAbsent
in interfaceRMap<K,V>
- Parameters:
key
- - map keyvalue
- - map value- Returns:
true
if key is a new one in the hash and value was set.false
if key already exists in the hash and change hasn't been made.
-
fastPutIfAbsentAsync
public RFuture<Boolean> fastPutIfAbsentAsync(K key, V value)
Description copied from interface:RMapAsync
Associates the specifiedvalue
with the specifiedkey
only if there is no any association with specifiedkey
.Works faster than
but not returning the previous value associated withRMapAsync.putIfAbsentAsync(Object, Object)
key
If
MapWriter
is defined then new map entry is stored in write-through mode.- Specified by:
fastPutIfAbsentAsync
in interfaceRMapAsync<K,V>
- Parameters:
key
- - map keyvalue
- - map value- Returns:
true
if key is a new one in the hash and value was set.false
if key already exists in the hash and change hasn't been made.
-
fastPutIfAbsentOperationAsync
protected RFuture<Boolean> fastPutIfAbsentOperationAsync(K key, V value)
-
remove
public boolean remove(Object key, Object value)
Description copied from interface:RMap
Removeskey
from map only if it associated withvalue
.If
MapWriter
is defined thenkey
is deleted in write-through mode.
-
removeAsync
public RFuture<Boolean> removeAsync(Object key, Object value)
Description copied from interface:RMapAsync
Removeskey
from map only if it associated withvalue
.If
MapWriter
is defined thenkey
is deleted in write-through mode.- Specified by:
removeAsync
in interfaceRMapAsync<K,V>
- Parameters:
key
- - map keyvalue
- - map value- Returns:
true
if map entry has been replaced otherwisefalse
.
-
checkValue
protected void checkValue(Object value)
-
replace
public boolean replace(K key, V oldValue, V newValue)
Description copied from interface:RMap
Replaces previousoldValue
with anewValue
associated with thekey
. If previous value doesn't exist or equal tooldValue
then method returnsfalse
.If
MapWriter
is defined thennewValue
is written in write-through mode.
-
replaceAsync
public RFuture<Boolean> replaceAsync(K key, V oldValue, V newValue)
Description copied from interface:RMapAsync
Replaces previousoldValue
with anewValue
associated with thekey
. If previous value doesn't exist or equal tooldValue
then method returnsfalse
.If
MapWriter
is defined thennewValue
is written in write-through mode.- Specified by:
replaceAsync
in interfaceRMapAsync<K,V>
- Parameters:
key
- - map keyoldValue
- - map old valuenewValue
- - map new value- Returns:
true
if value has been replaced otherwisefalse
.
-
replaceOperationAsync
protected RFuture<Boolean> replaceOperationAsync(K key, V oldValue, V newValue)
-
replace
public V replace(K key, V value)
Description copied from interface:RMap
Replaces previous value with a newvalue
associated with thekey
. If there wasn't any association before then method returnsnull
.If
MapWriter
is defined then newvalue
is written in write-through mode.
-
replaceAsync
public RFuture<V> replaceAsync(K key, V value)
Description copied from interface:RMapAsync
Replaces previous value with a newvalue
associated with thekey
. If there wasn't any association before then method returnsnull
.If
MapWriter
is defined then newvalue
is written in write-through mode.- Specified by:
replaceAsync
in interfaceRMapAsync<K,V>
- Parameters:
key
- - map keyvalue
- - map value- Returns:
- previous associated value
or
null
if there wasn't any association and change hasn't been made
-
fastReplace
public boolean fastReplace(K key, V value)
Description copied from interface:RMap
Replaces previous value with a newvalue
associated with thekey
.Works faster than
but not returning the previous value associated withRMap.replace(Object, Object)
key
If
MapWriter
is defined then new map entry is stored in write-through mode.- Specified by:
fastReplace
in interfaceRMap<K,V>
- Parameters:
key
- - map keyvalue
- - map value- Returns:
true
if key exists and value was updated.false
if key doesn't exists and value wasn't updated.
-
fastReplaceAsync
public RFuture<Boolean> fastReplaceAsync(K key, V value)
Description copied from interface:RMapAsync
Replaces previous value with a newvalue
associated with thekey
.Works faster than
but not returning the previous value associated withRMapAsync.replaceAsync(Object, Object)
key
If
MapWriter
is defined then new map entry is stored in write-through mode.- Specified by:
fastReplaceAsync
in interfaceRMapAsync<K,V>
- Parameters:
key
- - map keyvalue
- - map value- Returns:
true
if key exists and value was updated.false
if key doesn't exists and value wasn't updated.
-
getAsync
public RFuture<V> getAsync(K key)
Description copied from interface:RMapAsync
Returns the value to which the specified key is mapped, ornull
if this map contains no mapping for the key.If map doesn't contain value for specified key and
MapLoader
is defined then value will be loaded in read-through mode.
-
loadAll
public void loadAll(boolean replaceExistingValues, int parallelism)
Description copied from interface:RMap
Loads all map entries to this Redis map usingMapLoader
.
-
loadAllAsync
public RFuture<Void> loadAllAsync(boolean replaceExistingValues, int parallelism)
Description copied from interface:RMapAsync
Loads all map entries to this Redis map usingMapLoader
.- Specified by:
loadAllAsync
in interfaceRMapAsync<K,V>
- Parameters:
replaceExistingValues
- -true
if existed values should be replaced,false
otherwise.parallelism
- - parallelism level, used to increase speed of process execution- Returns:
- void
-
loadAll
public void loadAll(Set<? extends K> keys, boolean replaceExistingValues, int parallelism)
Description copied from interface:RMap
Loads map entries usingMapLoader
whose keys are listed in definedkeys
parameter.
-
loadAllAsync
public RFuture<Void> loadAllAsync(Set<? extends K> keys, boolean replaceExistingValues, int parallelism)
Description copied from interface:RMapAsync
Loads map entries usingMapLoader
whose keys are listed in definedkeys
parameter.- Specified by:
loadAllAsync
in interfaceRMapAsync<K,V>
- Parameters:
keys
- - map keysreplaceExistingValues
- -true
if existed values should be replaced,false
otherwise.parallelism
- - parallelism level, used to increase speed of process execution- Returns:
- void
-
putAsync
public RFuture<V> putAsync(K key, V value)
Description copied from interface:RMapAsync
Associates the specifiedvalue
with the specifiedkey
in async manner.If
MapWriter
is defined then new map entry is stored in write-through mode.
-
removeAsync
public RFuture<V> removeAsync(K key)
Description copied from interface:RMapAsync
Removeskey
from map and returns associated value in async manner.If
MapWriter
is defined thenkey
is deleted in write-through mode.- Specified by:
removeAsync
in interfaceRMapAsync<K,V>
- Parameters:
key
- - map key- Returns:
- deleted value or
null
if there wasn't any association
-
fastPutAsync
public RFuture<Boolean> fastPutAsync(K key, V value)
Description copied from interface:RMapAsync
Associates the specifiedvalue
with the specifiedkey
in async manner.Works faster than
but not returning the previous value associated withRMapAsync.putAsync(Object, Object)
key
If
MapWriter
is defined then new map entry is stored in write-through mode.- Specified by:
fastPutAsync
in interfaceRMapAsync<K,V>
- Parameters:
key
- - map keyvalue
- - map value- Returns:
true
if key is a new one in the hash and value was set.false
if key already exists in the hash and the value was updated.
-
fastPut
public boolean fastPut(K key, V value)
Description copied from interface:RMap
Associates the specifiedvalue
with the specifiedkey
.Works faster than
but not returning the previous value associated withRMap.put(Object, Object)
key
If
MapWriter
is defined then new map entry is stored in write-through mode.
-
fastRemoveAsync
public RFuture<Long> fastRemoveAsync(K... keys)
Description copied from interface:RMapAsync
Removeskeys
from map by one operation in async manner.Works faster than
but doesn't return the value associated withRMapAsync.removeAsync(Object, Object)
key
.If
MapWriter
is defined thenkeys
are deleted in write-through mode.- Specified by:
fastRemoveAsync
in interfaceRMapAsync<K,V>
- Parameters:
keys
- - map keys- Returns:
- the number of keys that were removed from the hash, not including specified but non existing keys
-
fastRemoveOperationBatchAsync
protected RFuture<List<Long>> fastRemoveOperationBatchAsync(K... keys)
-
fastRemove
public long fastRemove(K... keys)
Description copied from interface:RMap
Removeskeys
from map by one operationWorks faster than
but not returning the value associated withRMap.remove(Object)
key
If
MapWriter
is defined thenkeys
are deleted in write-through mode.- Specified by:
fastRemove
in interfaceRMap<K,V>
- Parameters:
keys
- - map keys- Returns:
- the number of keys that were removed from the hash, not including specified but non existing keys
-
scanIterator
public MapScanResult<Object,Object> scanIterator(String name, RedisClient client, long startPos, String pattern, int count)
-
scanIteratorAsync
public RFuture<MapScanResult<Object,Object>> scanIteratorAsync(String name, RedisClient client, long startPos, String pattern, int count)
-
addAndGet
public V addAndGet(K key, Number value)
Description copied from interface:RMap
Atomically adds the givendelta
to the current value by mappedkey
. Works only for numeric values!
-
addAndGetAsync
public RFuture<V> addAndGetAsync(K key, Number value)
Description copied from interface:RMapAsync
Atomically adds the givendelta
to the current value by mappedkey
. Works only for numeric values!- Specified by:
addAndGetAsync
in interfaceRMapAsync<K,V>
- Parameters:
key
- - map keyvalue
- - delta the value to add- Returns:
- the updated value
-
equals
public boolean equals(Object o)
-
hashCode
public int hashCode()
-
expire
public boolean expire(long timeToLive, TimeUnit timeUnit)
Description copied from interface:RExpirable
Set a timeout for object. After the timeout has expired, the key will automatically be deleted.- Specified by:
expire
in interfaceRExpirable
- Parameters:
timeToLive
- - timeout before object will be deletedtimeUnit
- - timeout time unit- Returns:
true
if the timeout was set andfalse
if not
-
expireAsync
public RFuture<Boolean> expireAsync(long timeToLive, TimeUnit timeUnit)
Description copied from interface:RExpirableAsync
Set a timeout for object in async mode. After the timeout has expired, the key will automatically be deleted.- Specified by:
expireAsync
in interfaceRExpirableAsync
- Parameters:
timeToLive
- - timeout before object will be deletedtimeUnit
- - timeout time unit- Returns:
true
if the timeout was set andfalse
if not
-
expireAt
public boolean expireAt(long timestamp)
Description copied from interface:RExpirable
Set an expire date for object. When expire date comes the key will automatically be deleted.- Specified by:
expireAt
in interfaceRExpirable
- Parameters:
timestamp
- - expire date in milliseconds (Unix timestamp)- Returns:
true
if the timeout was set andfalse
if not
-
expireAtAsync
public RFuture<Boolean> expireAtAsync(long timestamp)
Description copied from interface:RExpirableAsync
Set an expire date for object in async mode. When expire date comes the key will automatically be deleted.- Specified by:
expireAtAsync
in interfaceRExpirableAsync
- Parameters:
timestamp
- - expire date in milliseconds (Unix timestamp)- Returns:
true
if the timeout was set andfalse
if not
-
expireAt
public boolean expireAt(Date timestamp)
Description copied from interface:RExpirable
Set an expire date for object. When expire date comes the key will automatically be deleted.- Specified by:
expireAt
in interfaceRExpirable
- Parameters:
timestamp
- - expire date- Returns:
true
if the timeout was set andfalse
if not
-
expireAtAsync
public RFuture<Boolean> expireAtAsync(Date timestamp)
Description copied from interface:RExpirableAsync
Set an expire date for object in async mode. When expire date comes the key will automatically be deleted.- Specified by:
expireAtAsync
in interfaceRExpirableAsync
- Parameters:
timestamp
- - expire date- Returns:
true
if the timeout was set andfalse
if not
-
clearExpire
public boolean clearExpire()
Description copied from interface:RExpirable
Clear an expire timeout or expire date for object.- Specified by:
clearExpire
in interfaceRExpirable
- Returns:
true
if timeout was removedfalse
if object does not exist or does not have an associated timeout
-
clearExpireAsync
public RFuture<Boolean> clearExpireAsync()
Description copied from interface:RExpirableAsync
Clear an expire timeout or expire date for object in async mode. Object will not be deleted.- Specified by:
clearExpireAsync
in interfaceRExpirableAsync
- Returns:
true
if the timeout was cleared andfalse
if not
-
remainTimeToLive
public long remainTimeToLive()
Description copied from interface:RExpirable
Remaining time to live of Redisson object that has a timeout- Specified by:
remainTimeToLive
in interfaceRExpirable
- Returns:
- time in milliseconds -2 if the key does not exist. -1 if the key exists but has no associated expire.
-
remainTimeToLiveAsync
public RFuture<Long> remainTimeToLiveAsync()
Description copied from interface:RExpirableAsync
Remaining time to live of Redisson object that has a timeout- Specified by:
remainTimeToLiveAsync
in interfaceRExpirableAsync
- Returns:
- time in milliseconds -2 if the key does not exist. -1 if the key exists but has no associated expire.
-
-