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, Tihomir Mateev
-
Nested Class Summary
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultRedisMap(String key, RedisOperations<String, ?> operations) Constructs a newDefaultRedisMapinstance.DefaultRedisMap(BoundHashOperations<String, K, V> boundOps) Constructs a newDefaultRedisMapinstance. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()booleancontainsKey(Object key) booleancontainsValue(Object value) entrySet()booleanSets 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.inthashCode()Returns a bound operations object to perform operations on the hash field expiration for all hash fields at the boundBoundKeyOperations.getKey().hashFieldExpiration(Collection<K> hashFields) Returns a bound operations object to perform operations on the hash field expiration for all hash fields at the boundBoundKeyOperations.getKey()for the given hash fields.Incrementvalueof the hashkeyby the givendelta.Incrementvalueof the hashkeyby the givendelta.booleanisEmpty()keySet()persist()Removes the expiration (if any) of the key.voidputIfAbsent(K key, V value) Get a random entry from the hash.Get a random key from the hash.booleanvoidRenames the key.booleanscan()intsize()toString()values()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.data.redis.core.BoundKeyOperations
expiration, expire, expireAtMethods inherited from interface java.util.concurrent.ConcurrentMap
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, replaceAllMethods inherited from interface org.springframework.data.redis.support.collections.RedisMap
hashFieldExpiration
-
Constructor Details
-
DefaultRedisMap
Constructs a newDefaultRedisMapinstance.- Parameters:
key- Redis key of this map.operations-RedisOperationsfor this map.- See Also:
-
DefaultRedisMap
Constructs a newDefaultRedisMapinstance.- Parameters:
boundOps-BoundHashOperationsfor this map.
-
-
Method Details
-
increment
Description copied from interface:RedisMapIncrementvalueof the hashkeyby the givendelta. -
increment
Description copied from interface:RedisMapIncrementvalueof the hashkeyby the givendelta. -
randomKey
Description copied from interface:RedisMapGet a random key from the hash. -
randomEntry
Description copied from interface:RedisMapGet a random entry from the hash.- Specified by:
randomEntryin interfaceRedisMap<K,V> - Returns:
- null if the hash does not exist.
-
getOperations
Description copied from interface:RedisStoreReturns the underlying Redis operations used by the backing implementation.- Specified by:
getOperationsin interfaceBoundKeyOperations<K>- Specified by:
getOperationsin interfaceRedisStore- Returns:
- operations never null.
-
clear
public void clear() -
containsKey
- Specified by:
containsKeyin interfaceMap<K,V>
-
containsValue
- Specified by:
containsValuein 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:
putIfAbsentin interfaceConcurrentMap<K,V> - Specified by:
putIfAbsentin interfaceMap<K,V>
-
remove
-
replace
-
replace
-
expire
Description copied from interface:BoundKeyOperationsSets the key time-to-live/expiration.- Specified by:
expirein 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:BoundKeyOperationsSets the key time-to-live/expiration.- Specified by:
expireAtin 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:BoundKeyOperationsReturns the expiration of this key.- Specified by:
getExpirein interfaceBoundKeyOperations<K>- Returns:
- expiration value (in seconds). null when used in pipeline / transaction.
-
persist
Description copied from interface:BoundKeyOperationsRemoves the expiration (if any) of the key.- Specified by:
persistin interfaceBoundKeyOperations<K>- Returns:
- true if expiration was removed, false otherwise. null when used in pipeline / transaction.
-
getKey
Description copied from interface:BoundKeyOperationsReturns the key associated with this entity.- Specified by:
getKeyin interfaceBoundKeyOperations<K>- Returns:
- key associated with the implementing entity
-
rename
Description copied from interface:BoundKeyOperationsRenames the key.
Note: The new name for empty collections will be propagated on add of first element.- Specified by:
renamein interfaceBoundKeyOperations<K>- Parameters:
newKey- new key. Must not be null.
-
getType
Description copied from interface:BoundKeyOperationsReturns the associated Redis type.- Specified by:
getTypein interfaceBoundKeyOperations<K>- Returns:
- key type. null when used in pipeline / transaction.
-
scan
-
hashFieldExpiration
Description copied from interface:RedisMapReturns a bound operations object to perform operations on the hash field expiration for all hash fields at the boundBoundKeyOperations.getKey(). Operations on the expiration object obtain keys at the time of invoking any expiration operation.- Specified by:
hashFieldExpirationin interfaceRedisMap<K,V> - Returns:
- the bound operations object to perform operations on the hash field expiration.
-
hashFieldExpiration
Description copied from interface:RedisMapReturns a bound operations object to perform operations on the hash field expiration for all hash fields at the boundBoundKeyOperations.getKey()for the given hash fields.- Specified by:
hashFieldExpirationin interfaceRedisMap<K,V> - Parameters:
hashFields- collection of hash fields to operate on.- Returns:
- the bound operations object to perform operations on the hash field expiration.
-