Class RedissonMultimap<K,V>
- java.lang.Object
-
- org.redisson.RedissonObject
-
- org.redisson.RedissonMultimap<K,V>
-
- Type Parameters:
K
- keyV
- value
- All Implemented Interfaces:
RExpirable
,RExpirableAsync
,RMultimap<K,V>
,RMultimapAsync<K,V>
,RObject
,RObjectAsync
- Direct Known Subclasses:
RedissonListMultimap
,RedissonSetMultimap
public abstract class RedissonMultimap<K,V> extends RedissonObject implements RMultimap<K,V>
- Author:
- Nikita Koksharov
-
-
Field Summary
-
Fields inherited from class org.redisson.RedissonObject
codec, commandExecutor, name
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Removes all key-value pairs from the multimap, leaving it empty.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.protected RFuture<Boolean>
clearExpireAsync(String... keys)
boolean
containsEntry(Object key, Object value)
Returnstrue
if this multimap contains at least one key-value pair with the keykey
and the valuevalue
.boolean
containsKey(Object key)
Returnstrue
if this multimap contains at least one key-value pair with the keykey
.boolean
containsValue(Object value)
Returnstrue
if this multimap contains at least one key-value pair with the valuevalue
.RFuture<Boolean>
deleteAsync()
Delete object in async modeCollection<Map.Entry<K,V>>
entries()
Returns a view collection of all key-value pairs contained in this multimap, asMap.Entry
instances.boolean
expire(long timeToLive, TimeUnit timeUnit)
Set a timeout for object.boolean
expire(Instant instant)
Set an expire date for object.RFuture<Boolean>
expireAsync(long timeToLive, TimeUnit timeUnit)
Set a timeout for object in async mode.protected RFuture<Boolean>
expireAsync(long timeToLive, TimeUnit timeUnit, String... keys)
RFuture<Boolean>
expireAsync(Instant instant)
Set an expire date for object.boolean
expireAt(long timestamp)
UseRExpirable.expire(Instant)
insteadboolean
expireAt(Date timestamp)
UseRExpirable.expire(Instant)
insteadRFuture<Boolean>
expireAtAsync(long timestamp)
UseRExpirableAsync.expireAsync(Instant)
insteadprotected RFuture<Boolean>
expireAtAsync(long timestamp, String... keys)
RFuture<Boolean>
expireAtAsync(Date timestamp)
UseRExpirableAsync.expireAsync(Instant)
insteadlong
fastRemove(K... keys)
Removeskeys
from map by one operation Works faster thanRMultimap.remove
but not returning the value associated withkey
protected <T> RFuture<T>
fastRemoveAsync(List<Object> mapKeys, List<Object> listKeys, RedisCommand<T> evalCommandType)
RFuture<Long>
fastRemoveAsync(K... keys)
Removeskeys
from map by one operation Works faster thanRMultimap.remove
but not returning the value associated withkey
Collection<V>
getAll(K key)
Returns all elements at once.RCountDownLatch
getCountDownLatch(K key)
ReturnsRCountDownLatch
instance associated with keyRLock
getFairLock(K key)
ReturnsRLock
instance associated with keyRLock
getLock(K key)
ReturnsRLock
instance associated with keyRPermitExpirableSemaphore
getPermitExpirableSemaphore(K key)
ReturnsRPermitExpirableSemaphore
instance associated with keyRReadWriteLock
getReadWriteLock(K key)
ReturnsRReadWriteLock
instance associated with keyRSemaphore
getSemaphore(K key)
ReturnsRSemaphore
instance associated with keyprotected String
hash(io.netty.buffer.ByteBuf objectState)
boolean
isEmpty()
Check is map emptyprotected String
keyHash(Object key)
Set<K>
keySet()
Returns a view collection of all distinct keys contained in this multimap.int
keySize()
Returns the count of distinct keys in this multimap.RFuture<Integer>
keySizeAsync()
Returns the number of key-value pairs in this multimap.boolean
put(K key, V value)
Stores a key-value pair in this multimap.boolean
putAll(K key, Iterable<? extends V> values)
Stores a key-value pair in this multimap for each ofvalues
, all using the same key,key
.Set<K>
readAllKeySet()
Read all keys at onceRFuture<Set<K>>
readAllKeySetAsync()
Read all keys 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 timeoutboolean
remove(Object key, Object value)
Removes a single key-value pair with the keykey
and the valuevalue
from this multimap, if such exists.Collection<V>
removeAll(Object key)
Removes all values associated with the keykey
.RFuture<Void>
renameAsync(String newName)
Rename current object key tonewName
in async modeRFuture<Boolean>
renamenxAsync(String newName)
Rename current object key tonewName
in async mode only if new key is not existsCollection<V>
replaceValues(K key, Iterable<? extends V> values)
Stores a collection of values with the same key, replacing any existing values for that key.int
size()
Returns the number of key-value pairs in this multimap.RFuture<Long>
sizeInMemoryAsync()
Returns bytes amount used by object in Redis memory.Collection<V>
values()
Returns a view collection containing the value from each key-value pair contained in this multimap, without collapsing duplicates (sovalues().size() == size()
).-
Methods inherited from class org.redisson.RedissonObject
addListener, addListener, addListenerAsync, addListenerAsync, copy, copyAsync, delete, deleteAsync, dump, dumpAsync, encode, encode, encode, encode, encodeMapKey, encodeMapKeys, encodeMapValue, encodeMapValues, get, getCodec, getIdleTime, getIdleTimeAsync, getLockByMapKey, getLockByValue, getName, getRawName, getRawName, isExists, isExistsAsync, migrate, migrateAsync, move, moveAsync, prefixName, removeListener, removeListenerAsync, removeListenersAsync, rename, renamenx, restore, restore, restoreAndReplace, restoreAndReplace, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, setName, sizeInMemory, sizeInMemoryAsync, sizeInMemoryAsync, suffixName, toSeconds, toStream, touch, touchAsync, unlink, unlinkAsync
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.redisson.api.RExpirable
clearExpire, expire, expire, expireAt, expireAt, remainTimeToLive
-
Methods inherited from interface org.redisson.api.RExpirableAsync
expireAsync, expireAtAsync, expireAtAsync, remainTimeToLiveAsync
-
Methods inherited from interface org.redisson.api.RMultimapAsync
containsEntryAsync, containsKeyAsync, containsValueAsync, getAllAsync, putAllAsync, putAsync, removeAllAsync, removeAsync, replaceValuesAsync, sizeAsync
-
Methods inherited from interface org.redisson.api.RObject
addListener, copy, delete, dump, getCodec, getIdleTime, getName, isExists, migrate, move, removeListener, rename, renamenx, restore, restore, restoreAndReplace, restoreAndReplace, sizeInMemory, touch, unlink
-
Methods inherited from interface org.redisson.api.RObjectAsync
addListenerAsync, copyAsync, dumpAsync, getIdleTimeAsync, isExistsAsync, migrateAsync, moveAsync, removeListenerAsync, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, touchAsync, unlinkAsync
-
-
-
-
Method Detail
-
sizeInMemoryAsync
public RFuture<Long> sizeInMemoryAsync()
Description copied from interface:RObjectAsync
Returns bytes amount used by object in Redis memory.- Specified by:
sizeInMemoryAsync
in interfaceRObjectAsync
- Overrides:
sizeInMemoryAsync
in classRedissonObject
- Returns:
- size in bytes
-
getFairLock
public RLock getFairLock(K key)
Description copied from interface:RMultimap
ReturnsRLock
instance associated with key- Specified by:
getFairLock
in interfaceRMultimap<K,V>
- Parameters:
key
- - map key- Returns:
- fairlock
-
getPermitExpirableSemaphore
public RPermitExpirableSemaphore getPermitExpirableSemaphore(K key)
Description copied from interface:RMultimap
ReturnsRPermitExpirableSemaphore
instance associated with key- Specified by:
getPermitExpirableSemaphore
in interfaceRMultimap<K,V>
- Parameters:
key
- - map key- Returns:
- permitExpirableSemaphore
-
getCountDownLatch
public RCountDownLatch getCountDownLatch(K key)
Description copied from interface:RMultimap
ReturnsRCountDownLatch
instance associated with key- Specified by:
getCountDownLatch
in interfaceRMultimap<K,V>
- Parameters:
key
- - map key- Returns:
- countdownlatch
-
getSemaphore
public RSemaphore getSemaphore(K key)
Description copied from interface:RMultimap
ReturnsRSemaphore
instance associated with key- Specified by:
getSemaphore
in interfaceRMultimap<K,V>
- Parameters:
key
- - map key- Returns:
- semaphore
-
getLock
public RLock getLock(K key)
Description copied from interface:RMultimap
ReturnsRLock
instance associated with key
-
getReadWriteLock
public RReadWriteLock getReadWriteLock(K key)
Description copied from interface:RMultimap
ReturnsRReadWriteLock
instance associated with key- Specified by:
getReadWriteLock
in interfaceRMultimap<K,V>
- Parameters:
key
- - map key- Returns:
- readWriteLock
-
hash
protected String hash(io.netty.buffer.ByteBuf objectState)
-
size
public int size()
Description copied from interface:RMultimap
Returns the number of key-value pairs in this multimap.
-
keySize
public int keySize()
Description copied from interface:RMultimap
Returns the count of distinct keys in this multimap.
-
isEmpty
public boolean isEmpty()
Description copied from interface:RMultimap
Check is map empty
-
containsKey
public boolean containsKey(Object key)
Description copied from interface:RMultimap
Returnstrue
if this multimap contains at least one key-value pair with the keykey
.- Specified by:
containsKey
in interfaceRMultimap<K,V>
- Parameters:
key
- - map key- Returns:
true
if contains a key
-
containsValue
public boolean containsValue(Object value)
Description copied from interface:RMultimap
Returnstrue
if this multimap contains at least one key-value pair with the valuevalue
.- Specified by:
containsValue
in interfaceRMultimap<K,V>
- Parameters:
value
- - map value- Returns:
true
if contains a value
-
containsEntry
public boolean containsEntry(Object key, Object value)
Description copied from interface:RMultimap
Returnstrue
if this multimap contains at least one key-value pair with the keykey
and the valuevalue
.- Specified by:
containsEntry
in interfaceRMultimap<K,V>
- Parameters:
key
- - map keyvalue
- - map value- Returns:
true
if contains an entry
-
put
public boolean put(K key, V value)
Description copied from interface:RMultimap
Stores a key-value pair in this multimap.Some multimap implementations allow duplicate key-value pairs, in which case
put
always adds a new key-value pair and increases the multimap size by 1. Other implementations prohibit duplicates, and storing a key-value pair that's already in the multimap has no effect.
-
remove
public boolean remove(Object key, Object value)
Description copied from interface:RMultimap
Removes a single key-value pair with the keykey
and the valuevalue
from this multimap, if such exists. If multiple key-value pairs in the multimap fit this description, which one is removed is unspecified.
-
putAll
public boolean putAll(K key, Iterable<? extends V> values)
Description copied from interface:RMultimap
Stores a key-value pair in this multimap for each ofvalues
, all using the same key,key
. Equivalent to (but expected to be more efficient than):for (V value : values) { put(key, value); }
In particular, this is a no-op if
values
is empty.
-
clear
public void clear()
Description copied from interface:RMultimap
Removes all key-value pairs from the multimap, leaving it empty.
-
keySet
public Set<K> keySet()
Description copied from interface:RMultimap
Returns a view collection of all distinct keys contained in this multimap. Note that the key set contains a key if and only if this multimap maps that key to at least one value.Changes to the returned set will update the underlying multimap, and vice versa. However, adding to the returned set is not possible.
-
values
public Collection<V> values()
Description copied from interface:RMultimap
Returns a view collection containing the value from each key-value pair contained in this multimap, without collapsing duplicates (sovalues().size() == size()
).Changes to the returned collection will update the underlying multimap, and vice versa. However, adding to the returned collection is not possible.
-
getAll
public Collection<V> getAll(K key)
Description copied from interface:RMultimap
Returns all elements at once. Result collection is NOT backed by map, so changes are not reflected in map.
-
removeAll
public Collection<V> removeAll(Object key)
Description copied from interface:RMultimap
Removes all values associated with the keykey
.Once this method returns,
key
will not be mapped to any valuesUse
RMultimap.fastRemove(K...)
if values are not needed.
-
replaceValues
public Collection<V> replaceValues(K key, Iterable<? extends V> values)
Description copied from interface:RMultimap
Stores a collection of values with the same key, replacing any existing values for that key.If
values
is empty, this is equivalent toremoveAll(key)
.- Specified by:
replaceValues
in interfaceRMultimap<K,V>
- Parameters:
key
- - map keyvalues
- - map values- Returns:
- the collection of replaced values, or an empty collection if no values were previously associated with the key. The collection may be modifiable, but updating it will have no effect on the multimap.
-
entries
public Collection<Map.Entry<K,V>> entries()
Description copied from interface:RMultimap
Returns a view collection of all key-value pairs contained in this multimap, asMap.Entry
instances.Changes to the returned collection or the entries it contains will update the underlying multimap, and vice versa. However, adding to the returned collection is not possible.
-
readAllKeySet
public Set<K> readAllKeySet()
Description copied from interface:RMultimap
Read all keys at once- Specified by:
readAllKeySet
in interfaceRMultimap<K,V>
- Returns:
- keys
-
readAllKeySetAsync
public RFuture<Set<K>> readAllKeySetAsync()
Description copied from interface:RMultimapAsync
Read all keys at once- Specified by:
readAllKeySetAsync
in interfaceRMultimapAsync<K,V>
- Returns:
- keys
-
fastRemove
public long fastRemove(K... keys)
Description copied from interface:RMultimap
Removeskeys
from map by one operation Works faster thanRMultimap.remove
but not returning the value associated withkey
- Specified by:
fastRemove
in interfaceRMultimap<K,V>
- Parameters:
keys
- - map keys- Returns:
- the number of keys that were removed from the hash, not including specified but non existing keys
-
fastRemoveAsync
public RFuture<Long> fastRemoveAsync(K... keys)
Description copied from interface:RMultimapAsync
Removeskeys
from map by one operation Works faster thanRMultimap.remove
but not returning the value associated withkey
- Specified by:
fastRemoveAsync
in interfaceRMultimapAsync<K,V>
- Parameters:
keys
- - map keys- Returns:
- the number of keys that were removed from the hash, not including specified but non existing keys
-
fastRemoveAsync
protected <T> RFuture<T> fastRemoveAsync(List<Object> mapKeys, List<Object> listKeys, RedisCommand<T> evalCommandType)
-
deleteAsync
public RFuture<Boolean> deleteAsync()
Description copied from interface:RObjectAsync
Delete object in async mode- Specified by:
deleteAsync
in interfaceRObjectAsync
- Overrides:
deleteAsync
in classRedissonObject
- Returns:
true
if object was deletedfalse
if not
-
renameAsync
public RFuture<Void> renameAsync(String newName)
Description copied from interface:RObjectAsync
Rename current object key tonewName
in async mode- Specified by:
renameAsync
in interfaceRObjectAsync
- Overrides:
renameAsync
in classRedissonObject
- Parameters:
newName
- - new name of object- Returns:
- void
-
renamenxAsync
public RFuture<Boolean> renamenxAsync(String newName)
Description copied from interface:RObjectAsync
Rename current object key tonewName
in async mode only if new key is not exists- Specified by:
renamenxAsync
in interfaceRObjectAsync
- Overrides:
renamenxAsync
in classRedissonObject
- Parameters:
newName
- - new name of object- Returns:
true
if object has been renamed successfully andfalse
otherwise
-
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
-
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
-
keySizeAsync
public RFuture<Integer> keySizeAsync()
Description copied from interface:RMultimapAsync
Returns the number of key-value pairs in this multimap.- Specified by:
keySizeAsync
in interfaceRMultimapAsync<K,V>
- Returns:
- keys amount
-
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
-
expireAt
public boolean expireAt(long timestamp)
Description copied from interface:RExpirable
UseRExpirable.expire(Instant)
instead- 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
UseRExpirableAsync.expireAsync(Instant)
instead- Specified by:
expireAtAsync
in interfaceRExpirableAsync
- Parameters:
timestamp
- - expire date in milliseconds (Unix timestamp)- Returns:
true
if the timeout was set andfalse
if not
-
expire
public boolean expire(Instant instant)
Description copied from interface:RExpirable
Set an expire date for object. When expire date comes the key will automatically be deleted.- Specified by:
expire
in interfaceRExpirable
- Parameters:
instant
- - expire date- Returns:
true
if the timeout was set andfalse
if not
-
expireAsync
public RFuture<Boolean> expireAsync(Instant instant)
Description copied from interface:RExpirableAsync
Set an expire date for object. When expire date comes the key will automatically be deleted.- Specified by:
expireAsync
in interfaceRExpirableAsync
- Parameters:
instant
- - expire date- Returns:
true
if the timeout was set andfalse
if not
-
expireAt
public boolean expireAt(Date timestamp)
Description copied from interface:RExpirable
UseRExpirable.expire(Instant)
instead- 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
UseRExpirableAsync.expireAsync(Instant)
instead- 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
-
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.
-
expireAsync
protected RFuture<Boolean> expireAsync(long timeToLive, TimeUnit timeUnit, String... keys)
-
-