Interface RedisCacheWriter.TtlFunction
- All Known Implementing Classes:
FixedDurationTtlFunction
- Enclosing interface:
- RedisCacheWriter
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Function to compute the time to live from the cache
key and value.- Since:
- 3.2
- Author:
- Mark Paluch
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiongetTimeToLive(Object key, Object value) static RedisCacheWriter.TtlFunctionCreates a SingletonRedisCacheWriter.TtlFunctionusing the givenDuration.static RedisCacheWriter.TtlFunctionReturns aRedisCacheWriter.TtlFunctionto create persistent entires that do not expire.
-
Field Details
-
NO_EXPIRATION
-
-
Method Details
-
just
Creates a SingletonRedisCacheWriter.TtlFunctionusing the givenDuration.- Parameters:
duration- the time to live. Can beDuration.ZEROfor persistent values (i.e. cache entry does not expire).- Returns:
- a singleton
RedisCacheWriter.TtlFunctionusingDuration.
-
persistent
Returns aRedisCacheWriter.TtlFunctionto create persistent entires that do not expire.- Returns:
- a
RedisCacheWriter.TtlFunctionto create persistent entires that do not expire.
-
getTimeToLive
Compute atime-to-live (TTL)using the cachekeyandvalue.The
time-to-live (TTL)is computed on each write operation. Redis uses millisecond granularity for timeouts. Any more granular values (e.g. micros or nanos) are not considered and will be truncated due to rounding. ReturningDuration.ZERO, or a value less thanDuration.ofMillis(1), results in a persistent value that does not expire.- Parameters:
key- the cache key.value- the cache value. Can be null if the cache supports null value caching.- Returns:
- the computed
time-to-live (TTL). Can beDuration.ZEROfor persistent values (i.e. cache entry does not expire).
-