Closed
Description
Kyle Cronin opened DATAREDIS-858 and commented
RedisCache
should allow sub classes to define the TTL duration based on the cache key or value for use cases where the TTL is not know at configuration time or could change depending on the value being stored. For example access tokens where the token provider specifies how long the token is valid for.
public class RedisCache {
// default impementation delegates to cache config
@NonNull protected Duration getTtl(Object key, Object value) {
return cacheConfig.getTtl();
}
}
public class AccessTokenRedisCache extends RedisCache {
@Override
@NonNull
protected Duration getTtl(Object key, Object value) {
if (value instanceof AccessToken) {
return ((AccessToken) value).getTtl();
} else {
return super.getTtl(key, value);
}
}
}
If there was a way to specify a TTL policy in the RedisCacheConfiguration that would be bonus
No further details from DATAREDIS-858