Class Expirations.TimeToLive

java.lang.Object
org.springframework.data.redis.core.types.Expirations.TimeToLive
Enclosing class:
Expirations<K>

public static class Expirations.TimeToLive extends Object
Expiration holds time to live raw() values as returned by a Redis Client. value() serves the actual timeout in the given temporal context converting the raw() value into a target TimeUnit. Dedicated methods such as isPersistent() allow interpretation of the raw result. MISSING and PERSISTENT mark predefined states returned by Redis indicating a time to live value could not be retrieved due to various reasons.
  • Field Details

  • Method Details

    • of

      public static Expirations.TimeToLive of(Number value, TimeUnit timeUnit)
      Factory method for creating Expirations.TimeToLive instances, returning predefined ones if the value matches a known reserved state.
      Parameters:
      value - the TTL value.
      timeUnit - time unit for the given value.
      Returns:
      the Expirations.TimeToLive for the given raw value.
    • raw

      public long raw()
      The raw source value as returned by the Redis Client.
      Returns:
      the raw data.
    • value

      public long value()
      Returns:
      the raw() value converted into the requested target TimeUnit.
    • convert

      public Expirations.TimeToLive convert(TimeUnit timeUnit)
      Parameters:
      timeUnit - must not be null.
      Returns:
      the Expirations.TimeToLive instance with new target TimeUnit set for obtaining the value, or the same instance raw value cannot or must not be converted.
    • isPersistent

      public boolean isPersistent()
      Returns:
      true if key exists but does not expire.
    • isMissing

      public boolean isMissing()
      Returns:
      true if key does not exist and therefore does not have a time to live.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object