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
-
-
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.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.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.long
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.RLock
getLock(K key)
ReturnsRLock
instance associated with keyRReadWriteLock
getReadWriteLock(K key)
ReturnsRReadWriteLock
instance associated with keyprotected String
hash(io.netty.buffer.ByteBuf objectState)
protected String
hashAndRelease(io.netty.buffer.ByteBuf objectState)
boolean
isEmpty()
Check is map emptySet<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
.Collection<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.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
await, copy, copyAsync, delete, 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, sizeInMemory, sizeInMemoryAsync, sizeInMemoryAsync, suffixName, toSeconds, 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, expireAt, expireAt, remainTimeToLive
-
Methods inherited from interface org.redisson.api.RExpirableAsync
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
copy, delete, dump, getCodec, getName, isExists, migrate, move, rename, renamenx, restore, restore, restoreAndReplace, restoreAndReplace, sizeInMemory, touch, unlink
-
Methods inherited from interface org.redisson.api.RObjectAsync
copyAsync, dumpAsync, isExistsAsync, migrateAsync, moveAsync, renameAsync, renamenxAsync, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, sizeInMemoryAsync, touchAsync, unlinkAsync
-
-
-
-
Method Detail
-
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)
-
hashAndRelease
protected String hashAndRelease(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
-
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
-
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
-
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
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
-
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
-
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.
-
-