K - keyV - valuepublic class RedissonMapCacheReactive<K,V> extends Object implements RMapCacheReactive<K,V>
Map-based cache with ability to set TTL for each entry via
put(Object, Object, long, TimeUnit) or putIfAbsent(Object, Object, long, TimeUnit) method.
And therefore has an complex lua-scripts inside.
Current redis implementation doesnt have map entry eviction functionality.
Thus entries are checked for TTL expiration during any key/value/entry read operation.
If key/value/entry expired then it doesn't returns and clean task runs asynchronous.
Clean task deletes removes 100 expired entries at once.
In addition there is EvictionScheduler. This scheduler
deletes expired entries in time interval between 5 seconds to 2 hours.
If eviction is not required then it's better to use RedissonMapReactive.
| Constructor and Description |
|---|
RedissonMapCacheReactive(EvictionScheduler evictionScheduler,
Codec codec,
CommandReactiveExecutor commandExecutor,
String name,
MapOptions<K,V> options) |
RedissonMapCacheReactive(EvictionScheduler evictionScheduler,
CommandReactiveExecutor commandExecutor,
String name,
MapOptions<K,V> options) |
| Modifier and Type | Method and Description |
|---|---|
org.reactivestreams.Publisher<V> |
addAndGet(K key,
Number delta) |
org.reactivestreams.Publisher<Boolean> |
clearExpire()
Clear an expire timeout or expire date for object in mode.
|
org.reactivestreams.Publisher<Boolean> |
containsKey(Object key) |
org.reactivestreams.Publisher<Boolean> |
containsValue(Object value) |
org.reactivestreams.Publisher<Boolean> |
delete()
Delete object in mode
|
protected byte[] |
encode(Object value) |
protected byte[] |
encodeMapKey(Object value) |
protected byte[] |
encodeMapValue(Object value) |
org.reactivestreams.Publisher<Map.Entry<K,V>> |
entryIterator() |
boolean |
equals(Object o) |
org.reactivestreams.Publisher<Boolean> |
expire(long timeToLive,
TimeUnit timeUnit)
Set a timeout for object in mode.
|
org.reactivestreams.Publisher<Boolean> |
expireAt(Date timestamp)
Set an expire date for object in mode.
|
org.reactivestreams.Publisher<Boolean> |
expireAt(long timestamp)
Set an expire date for object in mode.
|
org.reactivestreams.Publisher<Boolean> |
fastPut(K key,
V value)
Associates the specified
value with the specified key
in async manner. |
org.reactivestreams.Publisher<Boolean> |
fastPut(K key,
V value,
long ttl,
TimeUnit unit)
Stores value mapped by key with specified time to live.
|
org.reactivestreams.Publisher<Boolean> |
fastPut(K key,
V value,
long ttl,
TimeUnit ttlUnit,
long maxIdleTime,
TimeUnit maxIdleUnit)
Stores value mapped by key with specified time to live and max idle time.
|
org.reactivestreams.Publisher<Boolean> |
fastPutIfAbsent(K key,
V value)
Associates the specified
value with the specified key
only if there is no any association with specifiedkey. |
org.reactivestreams.Publisher<Boolean> |
fastPutIfAbsent(K key,
V value,
long ttl,
TimeUnit ttlUnit,
long maxIdleTime,
TimeUnit maxIdleUnit)
If the specified key is not already associated
with a value, associate it with the given value.
|
org.reactivestreams.Publisher<Long> |
fastRemove(K... keys)
Removes
keys from map by one operation in async manner. |
org.reactivestreams.Publisher<V> |
get(K key)
Returns the value to which the specified key is mapped,
or
null if this map contains no mapping for the key. |
org.reactivestreams.Publisher<Map<K,V>> |
getAll(Set<K> keys)
Gets a map slice contained the mappings with defined
keys
by one operation. |
Codec |
getCodec() |
String |
getName() |
int |
hashCode() |
org.reactivestreams.Publisher<Boolean> |
isExists()
Check object existence
|
org.reactivestreams.Publisher<K> |
keyIterator() |
org.reactivestreams.Publisher<Void> |
loadAll(boolean replaceExistingValues,
int parallelism)
Loads all map entries to this Redis map.
|
org.reactivestreams.Publisher<Void> |
loadAll(Set<? extends K> keys,
boolean replaceExistingValues,
int parallelism)
Loads map entries whose keys are listed in defined
keys parameter. |
org.reactivestreams.Publisher<Void> |
migrate(String host,
int port,
int database)
Transfer a object from a source Redis instance to a destination Redis instance
in mode
|
org.reactivestreams.Publisher<Boolean> |
move(int database)
Move object to another database in mode
|
protected <V> reactor.rx.Stream<V> |
newSucceeded(V result) |
org.reactivestreams.Publisher<V> |
put(K key,
V value)
Associates the specified
value with the specified key
in async manner. |
org.reactivestreams.Publisher<V> |
put(K key,
V value,
long ttl,
TimeUnit unit)
Stores value mapped by key with specified time to live.
|
org.reactivestreams.Publisher<V> |
put(K key,
V value,
long ttl,
TimeUnit ttlUnit,
long maxIdleTime,
TimeUnit maxIdleUnit)
Stores value mapped by key with specified time to live and max idle time.
|
org.reactivestreams.Publisher<Void> |
putAll(Map<? extends K,? extends V> map)
Associates the specified
value with the specified key
in batch. |
org.reactivestreams.Publisher<V> |
putIfAbsent(K key,
V value)
Associates the specified
value with the specified key
only if there is no any association with specifiedkey. |
org.reactivestreams.Publisher<V> |
putIfAbsent(K key,
V value,
long ttl,
TimeUnit unit)
If the specified key is not already associated
with a value, associate it with the given value.
|
org.reactivestreams.Publisher<V> |
putIfAbsent(K key,
V value,
long ttl,
TimeUnit ttlUnit,
long maxIdleTime,
TimeUnit maxIdleUnit)
If the specified key is not already associated
with a value, associate it with the given value.
|
<R> org.reactivestreams.Publisher<R> |
reactive(reactor.fn.Supplier<RFuture<R>> supplier) |
org.reactivestreams.Publisher<Set<Map.Entry<K,V>>> |
readAllEntrySet()
Read all map entries at once
|
org.reactivestreams.Publisher<Set<K>> |
readAllKeySet()
Read all keys at once
|
org.reactivestreams.Publisher<Map<K,V>> |
readAllMap()
Read all map as local instance at once
|
org.reactivestreams.Publisher<Collection<V>> |
readAllValues()
Read all values at once
|
org.reactivestreams.Publisher<Long> |
remainTimeToLive()
Get remaining time to live of object in milliseconds.
|
org.reactivestreams.Publisher<V> |
remove(K key)
Removes
key from map and returns associated value in async manner. |
org.reactivestreams.Publisher<Boolean> |
remove(Object key,
Object value)
Removes
key from map only if it associated with value. |
org.reactivestreams.Publisher<Void> |
rename(String newName)
Rename current object key to
newName
in mode |
org.reactivestreams.Publisher<Boolean> |
renamenx(String newName)
Rename current object key to
newName
in mode only if new key is not exists |
org.reactivestreams.Publisher<V> |
replace(K key,
V value)
Replaces previous value with a new
value associated with the key. |
org.reactivestreams.Publisher<Boolean> |
replace(K key,
V oldValue,
V newValue)
Replaces previous
oldValue with a newValue associated with the key. |
org.reactivestreams.Publisher<MapScanResult<ScanObjectEntry,ScanObjectEntry>> |
scanIteratorReactive(InetSocketAddress client,
long startPos) |
org.reactivestreams.Publisher<Integer> |
size()
Returns the number of entries in cache.
|
org.reactivestreams.Publisher<V> |
valueIterator() |
org.reactivestreams.Publisher<Integer> |
valueSize(K key)
Returns size of value mapped by key in bytes
|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitexpireAt, remainTimeToLivepublic RedissonMapCacheReactive(EvictionScheduler evictionScheduler, CommandReactiveExecutor commandExecutor, String name, MapOptions<K,V> options)
public RedissonMapCacheReactive(EvictionScheduler evictionScheduler, Codec codec, CommandReactiveExecutor commandExecutor, String name, MapOptions<K,V> options)
public org.reactivestreams.Publisher<Boolean> containsKey(Object key)
containsKey in interface RMapReactive<K,V>public org.reactivestreams.Publisher<Boolean> containsValue(Object value)
containsValue in interface RMapReactive<K,V>public org.reactivestreams.Publisher<Map<K,V>> getAll(Set<K> keys)
RMapReactivekeys
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.
getAll in interface RMapReactive<K,V>keys - - map keyspublic org.reactivestreams.Publisher<V> putIfAbsent(K key, V value, long ttl, TimeUnit unit)
RMapCacheReactiveStores value mapped by key with specified time to live. Entry expires after specified time to live. If the map previously contained a mapping for the key, the old value is replaced by the specified value.
putIfAbsent in interface RMapCacheReactive<K,V>key - - map keyvalue - - map valuettl - - time to live for key\value entry.
If 0 then stores infinitely.unit - - time unitpublic org.reactivestreams.Publisher<Boolean> remove(Object key, Object value)
RMapReactivekey from map only if it associated with value.
If MapWriter is defined then keyis deleted in write-through mode.
remove in interface RMapReactive<K,V>key - - map keyvalue - - map valuetrue if map entry has been replaced otherwise false.public org.reactivestreams.Publisher<V> get(K key)
RMapReactivenull 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.
get in interface RMapReactive<K,V>key - the key whose associated value is to be returnednull if this map contains no mapping for the keypublic org.reactivestreams.Publisher<V> put(K key, V value, long ttl, TimeUnit unit)
RMapCacheReactiveput in interface RMapCacheReactive<K,V>key - - map keyvalue - - map valuettl - - time to live for key\value entry.
If 0 then stores infinitely.unit - - time unitpublic org.reactivestreams.Publisher<V> remove(K key)
RMapReactivekey from map and returns associated value in async manner.
If MapWriter is defined then keyis deleted in write-through mode.
remove in interface RMapReactive<K,V>key - - map keynull if there wasn't any associationpublic org.reactivestreams.Publisher<Long> fastRemove(K... keys)
RMapReactivekeys from map by one operation in async manner.
Works faster than but doesn't return
the value associated with RMapReactive.remove(Object, Object)key.
If MapWriter is defined then keysare deleted in write-through mode.
fastRemove in interface RMapReactive<K,V>keys - - map keyspublic org.reactivestreams.Publisher<MapScanResult<ScanObjectEntry,ScanObjectEntry>> scanIteratorReactive(InetSocketAddress client, long startPos)
public org.reactivestreams.Publisher<Boolean> delete()
RObjectReactivedelete in interface RObjectReactivetrue if object was deleted false if notpublic org.reactivestreams.Publisher<Boolean> expire(long timeToLive, TimeUnit timeUnit)
RExpirableReactiveexpire in interface RExpirableReactivetimeToLive - - timeout before object will be deletedtimeUnit - - timeout time unittrue if the timeout was set and false if notpublic org.reactivestreams.Publisher<Boolean> expireAt(long timestamp)
RExpirableReactiveexpireAt in interface RExpirableReactivetimestamp - - expire date in milliseconds (Unix timestamp)true if the timeout was set and false if notpublic org.reactivestreams.Publisher<Boolean> clearExpire()
RExpirableReactiveclearExpire in interface RExpirableReactivetrue if the timeout was cleared and false if notpublic org.reactivestreams.Publisher<Void> putAll(Map<? extends K,? extends V> map)
RMapReactivevalue with the specified key
in batch.
If MapWriter is defined then new map entries are stored in write-through mode.
putAll in interface RMapReactive<K,V>map - mappings to be stored in this mappublic org.reactivestreams.Publisher<V> addAndGet(K key, Number delta)
addAndGet in interface RMapReactive<K,V>public org.reactivestreams.Publisher<Boolean> fastPut(K key, V value)
RMapReactivevalue with the specified key
in async manner.
Works faster than but not returning
the previous value associated with RMapReactive.put(Object, Object)key
If MapWriter is defined then new map entry is stored in write-through mode.
fastPut in interface RMapReactive<K,V>key - - map keyvalue - - map valuetrue 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.public org.reactivestreams.Publisher<V> put(K key, V value)
RMapReactivevalue with the specified key
in async manner.
If MapWriter is defined then new map entry is stored in write-through mode.
put in interface RMapReactive<K,V>key - - map keyvalue - - map valuepublic org.reactivestreams.Publisher<V> replace(K key, V value)
RMapReactivevalue associated with the key.
If there wasn't any association before then method returns null.
If MapWriter is defined then new valueis written in write-through mode.
replace in interface RMapReactive<K,V>key - - map keyvalue - - map valuenull if there wasn't any association and change hasn't been madepublic org.reactivestreams.Publisher<Boolean> replace(K key, V oldValue, V newValue)
RMapReactiveoldValue with a newValue associated with the key.
If previous value doesn't exist or equal to oldValue then method returns false.
If MapWriter is defined then newValueis written in write-through mode.
replace in interface RMapReactive<K,V>key - - map keyoldValue - - map old valuenewValue - - map new valuetrue if value has been replaced otherwise false.public org.reactivestreams.Publisher<V> putIfAbsent(K key, V value)
RMapReactivevalue with the specified key
only if there is no any association with specifiedkey.
If MapWriter is defined then new map entry is stored in write-through mode.
putIfAbsent in interface RMapReactive<K,V>key - - map keyvalue - - map valuenull 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.public org.reactivestreams.Publisher<Map.Entry<K,V>> entryIterator()
entryIterator in interface RMapReactive<K,V>public org.reactivestreams.Publisher<V> valueIterator()
valueIterator in interface RMapReactive<K,V>public org.reactivestreams.Publisher<K> keyIterator()
keyIterator in interface RMapReactive<K,V>public org.reactivestreams.Publisher<Integer> size()
RMapCacheReactivesize in interface RMapCacheReactive<K,V>size in interface RMapReactive<K,V>public org.reactivestreams.Publisher<Void> loadAll(boolean replaceExistingValues, int parallelism)
RMapReactiveloadAll in interface RMapReactive<K,V>replaceExistingValues - - true if existed values should be replaced, false otherwise.parallelism - - parallelism level, used to increase speed of process executionpublic org.reactivestreams.Publisher<Void> loadAll(Set<? extends K> keys, boolean replaceExistingValues, int parallelism)
RMapReactivekeys parameter.loadAll in interface RMapReactive<K,V>keys - - map keysreplaceExistingValues - - true if existed values should be replaced, false otherwise.parallelism - - parallelism level, used to increase speed of process executionpublic org.reactivestreams.Publisher<Integer> valueSize(K key)
RMapReactivevalueSize in interface RMapReactive<K,V>key - - map keypublic org.reactivestreams.Publisher<Boolean> fastPutIfAbsent(K key, V value)
RMapReactivevalue with the specified key
only if there is no any association with specifiedkey.
Works faster than but not returning
the previous value associated with RMapReactive.putIfAbsent(Object, Object)key
If MapWriter is defined then new map entry is stored in write-through mode.
fastPutIfAbsent in interface RMapReactive<K,V>key - - map keyvalue - - map valuetrue 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.public org.reactivestreams.Publisher<Set<K>> readAllKeySet()
RMapReactivereadAllKeySet in interface RMapReactive<K,V>public org.reactivestreams.Publisher<Collection<V>> readAllValues()
RMapReactivereadAllValues in interface RMapReactive<K,V>public org.reactivestreams.Publisher<Set<Map.Entry<K,V>>> readAllEntrySet()
RMapReactivereadAllEntrySet in interface RMapReactive<K,V>public org.reactivestreams.Publisher<Map<K,V>> readAllMap()
RMapReactivereadAllMap in interface RMapReactive<K,V>public org.reactivestreams.Publisher<V> putIfAbsent(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
RMapCacheReactiveStores value mapped by key with specified time to live and max idle time. Entry expires when specified time to live or max idle time has expired.
If the map previously contained a mapping for the key, the old value is replaced by the specified value.
putIfAbsent in interface RMapCacheReactive<K,V>key - - map keyvalue - - map valuettl - - time to live for key\value entry.
If 0 then time to live doesn't affect entry expiration.ttlUnit - - time unitmaxIdleTime - - max idle time for key\value entry.
If 0 then max idle time doesn't affect entry expiration.maxIdleUnit - - time unit
if maxIdleTime and ttl params are equal to 0
then entry stores infinitely.
public org.reactivestreams.Publisher<V> put(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
RMapCacheReactiveIf the map previously contained a mapping for the key, the old value is replaced by the specified value.
put in interface RMapCacheReactive<K,V>key - - map keyvalue - - map valuettl - - time to live for key\value entry.
If 0 then time to live doesn't affect entry expiration.ttlUnit - - time unitmaxIdleTime - - max idle time for key\value entry.
If 0 then max idle time doesn't affect entry expiration.maxIdleUnit - - time unit
if maxIdleTime and ttl params are equal to 0
then entry stores infinitely.
public org.reactivestreams.Publisher<Boolean> fastPut(K key, V value, long ttl, TimeUnit unit)
RMapCacheReactiveIf the map previously contained a mapping for the key, the old value is replaced by the specified value.
Works faster than usual RMapCacheReactive.put(Object, Object, long, TimeUnit)
as it not returns previous value.
fastPut in interface RMapCacheReactive<K,V>key - - map keyvalue - - map valuettl - - time to live for key\value entry.
If 0 then stores infinitely.unit - - time unittrue if key is a new key in the hash and value was set.
false if key already exists in the hash and the value was updated.public org.reactivestreams.Publisher<Boolean> fastPut(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
RMapCacheReactiveIf the map previously contained a mapping for the key, the old value is replaced by the specified value.
Works faster than usual RMapCacheReactive.put(Object, Object, long, TimeUnit, long, TimeUnit)
as it not returns previous value.
fastPut in interface RMapCacheReactive<K,V>key - - map keyvalue - - map valuettl - - time to live for key\value entry.
If 0 then time to live doesn't affect entry expiration.ttlUnit - - time unitmaxIdleTime - - max idle time for key\value entry.
If 0 then max idle time doesn't affect entry expiration.maxIdleUnit - - time unit
if maxIdleTime and ttl params are equal to 0
then entry stores infinitely.
true if key is a new key in the hash and value was set.
false if key already exists in the hash and the value was updated.public org.reactivestreams.Publisher<Boolean> fastPutIfAbsent(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
RMapCacheReactiveStores value mapped by key with specified time to live and max idle time. Entry expires when specified time to live or max idle time has expired.
Works faster than usual RMapCacheReactive.putIfAbsent(Object, Object, long, TimeUnit, long, TimeUnit)
as it not returns previous value.
fastPutIfAbsent in interface RMapCacheReactive<K,V>key - - map keyvalue - - map valuettl - - time to live for key\value entry.
If 0 then time to live doesn't affect entry expiration.ttlUnit - - time unitmaxIdleTime - - max idle time for key\value entry.
If 0 then max idle time doesn't affect entry expiration.maxIdleUnit - - time unit
if maxIdleTime and ttl params are equal to 0
then entry stores infinitely.
true if key is a new key in the hash and value was set.
false if key already exists in the hashpublic org.reactivestreams.Publisher<Boolean> expireAt(Date timestamp)
RExpirableReactiveexpireAt in interface RExpirableReactivetimestamp - - expire datetrue if the timeout was set and false if notpublic org.reactivestreams.Publisher<Long> remainTimeToLive()
RExpirableReactiveremainTimeToLive in interface RExpirableReactivepublic <R> org.reactivestreams.Publisher<R> reactive(reactor.fn.Supplier<RFuture<R>> supplier)
protected <V> reactor.rx.Stream<V> newSucceeded(V result)
public String getName()
getName in interface RObjectReactivepublic Codec getCodec()
getCodec in interface RObjectReactiveprotected byte[] encode(Object value)
protected byte[] encodeMapKey(Object value)
protected byte[] encodeMapValue(Object value)
public org.reactivestreams.Publisher<Void> rename(String newName)
RObjectReactivenewName
in moderename in interface RObjectReactivenewName - - new name of objectpublic org.reactivestreams.Publisher<Void> migrate(String host, int port, int database)
RObjectReactivemigrate in interface RObjectReactivehost - - destination hostport - - destination portdatabase - - destination databasepublic org.reactivestreams.Publisher<Boolean> move(int database)
RObjectReactivemove in interface RObjectReactivedatabase - - number of Redis databasetrue if key was moved false if notpublic org.reactivestreams.Publisher<Boolean> renamenx(String newName)
RObjectReactivenewName
in mode only if new key is not existsrenamenx in interface RObjectReactivenewName - - new name of objecttrue if object has been renamed successfully and false otherwisepublic org.reactivestreams.Publisher<Boolean> isExists()
RObjectReactiveisExists in interface RObjectReactivetrue if object exists and false otherwiseCopyright © 2014–2017 The Redisson Project. All rights reserved.