Class DefaultRedisMap<K,V>
java.lang.Object
org.springframework.data.redis.support.collections.DefaultRedisMap<K,V>
- All Implemented Interfaces:
ConcurrentMap<K,
,V> Map<K,
,V> BoundKeyOperations<String>
,RedisMap<K,
,V> RedisStore
Default implementation for
RedisMap
. Note that the current implementation doesn't provide the same locking
semantics across all methods. In highly concurrent environments, race conditions might appear.- Author:
- Costin Leau, Christoph Strobl, Christian Bühler
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionDefaultRedisMap
(String key, RedisOperations<String, ?> operations) Constructs a newDefaultRedisMap
instance.DefaultRedisMap
(BoundHashOperations<String, K, V> boundOps) Constructs a newDefaultRedisMap
instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
boolean
containsKey
(Object key) boolean
containsValue
(Object value) entrySet()
boolean
Sets the key time-to-live/expiration.Sets the key time-to-live/expiration.Returns the expiration of this key.getKey()
Returns the key associated with this entity.Returns the underlying Redis operations used by the backing implementation.getType()
Returns the associated Redis type.int
hashCode()
Incrementvalue
of the hashkey
by the givendelta
.Incrementvalue
of the hashkey
by the givendelta
.boolean
isEmpty()
keySet()
persist()
Removes the expiration (if any) of the key.void
putIfAbsent
(K key, V value) Get a random entry from the hash.Get a random key from the hash.boolean
void
Renames the key.boolean
scan()
int
size()
toString()
values()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.data.redis.core.BoundKeyOperations
expire, expireAt
Methods inherited from interface java.util.concurrent.ConcurrentMap
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, replaceAll
-
Constructor Details
-
DefaultRedisMap
Constructs a newDefaultRedisMap
instance.- Parameters:
key
- Redis key of this map.operations
-RedisOperations
for this map.- See Also:
-
DefaultRedisMap
Constructs a newDefaultRedisMap
instance.- Parameters:
boundOps
-BoundHashOperations
for this map.
-
-
Method Details
-
increment
Description copied from interface:RedisMap
Incrementvalue
of the hashkey
by the givendelta
. -
increment
Description copied from interface:RedisMap
Incrementvalue
of the hashkey
by the givendelta
. -
randomKey
Description copied from interface:RedisMap
Get a random key from the hash. -
randomEntry
Description copied from interface:RedisMap
Get a random entry from the hash.- Specified by:
randomEntry
in interfaceRedisMap<K,
V> - Returns:
- null if the hash does not exist.
-
getOperations
Description copied from interface:RedisStore
Returns the underlying Redis operations used by the backing implementation.- Specified by:
getOperations
in interfaceRedisStore
- Returns:
- operations never null.
-
clear
public void clear() -
containsKey
- Specified by:
containsKey
in interfaceMap<K,
V>
-
containsValue
- Specified by:
containsValue
in interfaceMap<K,
V>
-
entrySet
-
get
-
isEmpty
public boolean isEmpty() -
keySet
-
put
-
putAll
-
remove
-
size
public int size() -
values
-
equals
-
hashCode
public int hashCode() -
toString
-
putIfAbsent
- Specified by:
putIfAbsent
in interfaceConcurrentMap<K,
V> - Specified by:
putIfAbsent
in interfaceMap<K,
V>
-
remove
-
replace
-
replace
-
expire
Description copied from interface:BoundKeyOperations
Sets the key time-to-live/expiration.- Specified by:
expire
in interfaceBoundKeyOperations<K>
- Parameters:
timeout
- expiration valueunit
- expiration unit- Returns:
- true if expiration was set, false otherwise. null when used in pipeline / transaction.
-
expireAt
Description copied from interface:BoundKeyOperations
Sets the key time-to-live/expiration.- Specified by:
expireAt
in interfaceBoundKeyOperations<K>
- Parameters:
date
- expiration date- Returns:
- true if expiration was set, false otherwise. null when used in pipeline / transaction.
-
getExpire
Description copied from interface:BoundKeyOperations
Returns the expiration of this key.- Specified by:
getExpire
in interfaceBoundKeyOperations<K>
- Returns:
- expiration value (in seconds). null when used in pipeline / transaction.
-
persist
Description copied from interface:BoundKeyOperations
Removes the expiration (if any) of the key.- Specified by:
persist
in interfaceBoundKeyOperations<K>
- Returns:
- true if expiration was removed, false otherwise. null when used in pipeline / transaction.
-
getKey
Description copied from interface:BoundKeyOperations
Returns the key associated with this entity.- Specified by:
getKey
in interfaceBoundKeyOperations<K>
- Returns:
- key associated with the implementing entity
-
rename
Description copied from interface:BoundKeyOperations
Renames the key.
Note: The new name for empty collections will be propagated on add of first element.- Specified by:
rename
in interfaceBoundKeyOperations<K>
- Parameters:
newKey
- new key. Must not be null.
-
getType
Description copied from interface:BoundKeyOperations
Returns the associated Redis type.- Specified by:
getType
in interfaceBoundKeyOperations<K>
- Returns:
- key type. null when used in pipeline / transaction.
-
scan
-