Class Expiration
java.lang.Object
org.springframework.data.redis.core.types.Expiration
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedExpiration(long expirationTime, TimeUnit timeUnit) Creates newExpiration. -
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic ExpirationCreates newExpirationwith the providedTimeUnit.static ExpirationCreates a newExpirationwith the given, requiredDuration.longgetConverted(TimeUnit targetTimeUnit) Convertsexpiration timeinto the given, desiredTimeUnit.longGet thelength of timefor thisExpiration.longGet theexpiration timeconverted intoTimeUnit.MILLISECONDS.longGet theexpiration timeconverted intoTimeUnit.SECONDS.Get the configuredTimeUnitfor theexpiration time.inthashCode()booleanbooleanbooleanstatic ExpirationkeepTtl()Obtain anExpirationthat indicates to keep the existing one, e.g. when sending aSETcommand.static Expirationmilliseconds(long expirationTime) Creates a newExpirationinTimeUnit.MILLISECONDS.static ExpirationCreates a new persistent, non-expiringExpiration.static Expirationseconds(long expirationTime) Creates a newExpirationinTimeUnit.SECONDS.static ExpirationunixTimestamp(long unixTimestamp, TimeUnit timeUnit) Creates a newExpirationwith the given unix timestamp andTimeUnit.
-
Constructor Details
-
Expiration
Creates newExpiration.- Parameters:
expirationTime-length of timefor expiration. Defaulted toTimeUnit.SECONDS.timeUnit-TimeUnitused to measureexpirationTime.
-
-
Method Details
-
milliseconds
Creates a newExpirationinTimeUnit.MILLISECONDS.- Parameters:
expirationTime-length of timefor expiration.- Returns:
- a new
Expirationmeasured inTimeUnit.MILLISECONDS.
-
seconds
Creates a newExpirationinTimeUnit.SECONDS.- Parameters:
expirationTime-length of timefor expiration.- Returns:
- a new
Expirationmeasured inTimeUnit.SECONDS.
-
unixTimestamp
Creates a newExpirationwith the given unix timestamp andTimeUnit.- Parameters:
unixTimestamp-unix timestampat which the key will expire.timeUnit-TimeUnitused to measure the expiration period; must not be null.- Returns:
- a new
Expirationwith the given unix timestamp andTimeUnit.
-
from
Creates newExpirationwith the providedTimeUnit. Greater units thanTimeUnit.SECONDSare converted toTimeUnit.SECONDS. Units smaller thanTimeUnit.MILLISECONDSare converted toTimeUnit.MILLISECONDSand can lose precision sinceTimeUnit.MILLISECONDSis the smallest granularity supported by Redis.- Parameters:
expirationTime-length of timefor theExpiration.timeUnit-TimeUnitused to measure theexpiration time; can be null. Defaulted toTimeUnit.SECONDS- Returns:
- a new
Expirationconfigured with the givenlength of timeinTimeUnit.
-
from
Creates a newExpirationwith the given, requiredDuration.Durations with at least seconds resolution uses
TimeUnit.SECONDS.Durationsin milliseconds useTimeUnit.MILLISECONDS.- Parameters:
duration- must not be null.- Returns:
- a new
Expirationfrom the givenDuration. - Since:
- 2.0
-
keepTtl
Obtain anExpirationthat indicates to keep the existing one, e.g. when sending aSETcommand.NOTE: Please follow the documentation for the individual commands to see if keeping the existing TTL is applicable.
- Returns:
- never null.
- Since:
- 2.4
-
persistent
Creates a new persistent, non-expiringExpiration.- Returns:
- a new persistent, non-expiring
Expiration.
-
getExpirationTime
public long getExpirationTime()Get thelength of timefor thisExpiration.- Returns:
- the
length of timefor thisExpiration.
-
getExpirationTimeInMilliseconds
public long getExpirationTimeInMilliseconds()Get theexpiration timeconverted intoTimeUnit.MILLISECONDS.- Returns:
- the expiration time converted into
TimeUnit.MILLISECONDS.
-
getExpirationTimeInSeconds
public long getExpirationTimeInSeconds()Get theexpiration timeconverted intoTimeUnit.SECONDS.- Returns:
- the
expiration timeconverted intoTimeUnit.SECONDS.
-
getTimeUnit
Get the configuredTimeUnitfor theexpiration time.- Returns:
- the configured
TimeUnitfor theexpiration time.
-
getConverted
Convertsexpiration timeinto the given, desiredTimeUnit.- Parameters:
targetTimeUnit-TimeUnitused to convert thegetExpirationTime()expiration time}; must not be null.- Returns:
- the
expiration timeconverted into the given, desiredTimeUnit. - Throws:
IllegalArgumentException- if the givenTimeUnitis null.
-
isPersistent
public boolean isPersistent()- Returns:
- true if
Expirationis set to persistent.
-
isKeepTtl
public boolean isKeepTtl()- Returns:
- true if
Expirationof existing key should not be modified. - Since:
- 2.4
-
isUnixTimestamp
public boolean isUnixTimestamp()- Returns:
- true if
Expirationis set to a specified Unix time at which the key will expire. - Since:
- 2.6
-
equals
-
hashCode
public int hashCode()
-