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 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.
    • getExpire

      @Nullable Long getExpire()
      Returns the expiration of this key.
      Returns:
      expiration value (in seconds). null when used in pipeline / transaction.
    • expire

      @Nullable default Boolean expire(Duration timeout)
      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

      @Nullable Boolean expire(long timeout, TimeUnit unit)
      Sets the key time-to-live/expiration.
      Parameters:
      timeout - expiration value
      unit - expiration unit
      Returns:
      true if expiration was set, false otherwise. null when used in pipeline / transaction.
    • expireAt

      @Nullable Boolean expireAt(Date date)
      Sets the key time-to-live/expiration.
      Parameters:
      date - expiration date
      Returns:
      true if expiration was set, false otherwise. null when used in pipeline / transaction.
    • expireAt

      @Nullable default Boolean expireAt(Instant 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 a Date.
      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

      void rename(K newKey)
      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.