Interface BoundKeyOperations<K>
- All Known Subinterfaces:
BoundGeoOperations<K,M>, BoundHashOperations<H, HK, HV>, BoundListOperations<K, V>, BoundSetOperations<K, V>, BoundValueOperations<K, V>, BoundZSetOperations<K, V>, RedisCollection<E>, RedisList<E>, RedisMap<K, V>, RedisSet<E>, RedisStore, RedisZSet<E>
- All Known Implementing Classes:
AbstractRedisCollection, DefaultRedisList, DefaultRedisMap, DefaultRedisSet, DefaultRedisZSet, RedisAtomicDouble, RedisAtomicInteger, RedisAtomicLong, RedisProperties
public interface BoundKeyOperations<K>
Operations over a Redis key. Useful for executing common key-'bound' operations to all implementations.
As the rest of the APIs, if the underlying connection is pipelined or queued/in multi mode, all methods will return null.
- Author:
- Costin Leau, Christoph Strobl, Mark Paluch
-
Method Summary
Modifier and TypeMethodDescriptiondefault BoundKeyExpirationOperationsReturns a bound operations object to perform expiration operations on the bound key.@Nullable BooleanSets the key time-to-live/expiration.default @Nullable BooleanSets the key time-to-live/expiration.default @Nullable BooleanSets the key time-to-live/expiration.@Nullable BooleanSets the key time-to-live/expiration.@Nullable LongReturns the expiration of this key.getKey()Returns the key associated with this entity.RedisOperations<K, ?> @Nullable DataTypegetType()Returns the associated Redis type.@Nullable Booleanpersist()Removes the expiration (if any) of the key.voidRenames the key.
-
Method Details
-
getKey
K getKey()Returns the key associated with this entity.- Returns:
- key associated with the implementing entity
-
getType
@Nullable DataType getType()Returns the associated Redis type.- Returns:
- key type. null when used in pipeline / transaction.
-
expiration
Returns a bound operations object to perform expiration operations on the bound key.- Returns:
- the bound operations object to perform operations on the hash field expiration.
- Since:
- 3.5
-
getExpire
@Nullable Long getExpire()Returns the expiration of this key.- Returns:
- expiration value (in seconds). null when used in pipeline / transaction.
-
expire
Sets the key time-to-live/expiration.- Parameters:
timeout- must not be null.- Returns:
- true if expiration was set, false otherwise. null when used in pipeline / transaction.
- Throws:
IllegalArgumentException- if the timeout is null.- Since:
- 2.3
-
expire
-
expireAt
-
expireAt
Sets the key time-to-live/expiration.- Parameters:
expireAt- expiration time.- Returns:
- true if expiration was set, false otherwise. null when used in pipeline / transaction.
- Throws:
IllegalArgumentException- if the instant is null or too large to represent as aDate.- Since:
- 2.3
-
persist
@Nullable Boolean persist()Removes the expiration (if any) of the key.- Returns:
- true if expiration was removed, false otherwise. null when used in pipeline / transaction.
-
rename
Renames the key.
Note: The new name for empty collections will be propagated on add of first element.- Parameters:
newKey- new key. Must not be null.
-
getOperations
RedisOperations<K,?> getOperations()- Returns:
- the underlying
RedisOperationsused to execute commands.
-