Reinstate RedisCacheConfiguration.getTtl().
Reintroduce and deprecate RedisCacheConfiguration.getTtl for backwards compatibility. Closes #2628 Original Pull Request: #2597
This commit is contained in:
committed by
Christoph Strobl
parent
65f628ab76
commit
fe88d31d09
@@ -326,6 +326,26 @@ public class RedisCacheConfiguration {
|
||||
return this.valueSerializationPair;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a computed {@link Duration TTL expiration timeout} based on cache entry key/value
|
||||
* if a {@link TtlFunction} was confiugred using {@link #entryTtl(TtlFunction)}.
|
||||
* <p>
|
||||
* Otherwise, returns the user-provided, fixed {@link Duration} if {@link #entryTtl(Duration)}
|
||||
* was called during cache configuration.
|
||||
*
|
||||
* @return the configured {@link Duration TTL expiration}.
|
||||
* @deprecated use {@link #getTtlFunction()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("all")
|
||||
public Duration getTtl() {
|
||||
|
||||
TtlFunction ttlFunction = getTtlFunction();
|
||||
|
||||
return ttlFunction instanceof FixedDurationTtlFunction it ? it.duration()
|
||||
: ttlFunction.getTimeToLive(null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link TtlFunction} used to compute a cache key {@literal time-to-live (TTL) expiration}.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user