Skip to content

Reinstate RedisCacheConfiguration.getTtl() #2629

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

Reinstate RedisCacheConfiguration.getTtl() #2629

wants to merge 2 commits into from

Conversation

jxblum
Copy link
Contributor

@jxblum jxblum commented Jul 6, 2023

See #2628

@jxblum jxblum requested a review from mp911de July 6, 2023 18:01
@jxblum jxblum added type: task A general task in: cache RedisCache and CacheManager labels Jul 6, 2023
@jxblum jxblum added this to the 3.2 M1 (2023.1.0) milestone Jul 6, 2023
@jxblum jxblum requested a review from christophstrobl July 6, 2023 18:03
@jxblum jxblum changed the title Reinstate RedisCacheConfiguration.getTtl(). Reinstate RedisCacheConfiguration.getTtl() Jul 6, 2023
Comment on lines +345 to +346
return ttlFunction instanceof FixedDurationTtlFunction it ? it.duration()
: ttlFunction.getTimeToLive(null, null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The key parameter of TtlFunction#getTimeToLive does not seem to be nullable. Also why cast to FixedDurationTtlFunction?

Copy link
Contributor Author

@jxblum jxblum Jul 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why a null key?

Because this is what the old, mistakingly removed, now deprecated (once again) getTtl() method did with the introduction of dynamic TTL cache configuration using the new RedisCacheWriter.TtlFunction interface.

See original Issue tickets and Pull Requests referenced in Issue #2628.

Copy link
Contributor Author

@jxblum jxblum Jul 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why cast to FixedDurationTtlFunction?

Because it is still possible to configure a "fixed" Duration TTL cache entry expiration policy using the overloaded entryTtl(:Duration) (source) builder method in RedisCacheConfiguration.

NOTE: entryTtl(:Duration) (fixed) is an alternative to entryTtl(:TtlFunction) (dynamic; here), hence the overload. Internally, a "fixed" Duration is still represented with a TtlFunction.

From this line, it will then create a (non-dynamically computed) FixedDurationTtlFunction instance (here).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FixedDurationTtlFunction#getTimeToLive would return the duration nevertheless, so really I do not see the need for a cast here.

Copy link
Contributor Author

@jxblum jxblum Jul 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Outside of a potential JVM runtime optimization here, it is true, there probably is no a need for the instance of check and implicit cast to a FixedDurationTtlFunction and direct call to the duration() method.

Feel free to change it in the polishing commit if you like. Otherwise, let me know, and I can take care of it.

@jxblum
Copy link
Contributor Author

jxblum commented Jul 14, 2023

Merged in commits fe88d31 & d25de89.

@jxblum jxblum closed this Jul 14, 2023
@mp911de mp911de deleted the issue/2628 branch July 14, 2023 07:02
@mp911de mp911de linked an issue Jul 14, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: cache RedisCache and CacheManager type: task A general task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reinstate RedisCacheConfiguration.getTtl() as deprecated
2 participants