Skip to content
Discussion options

You must be logged in to vote

Is there any way to query the TTL configured via expireAfter even when no entry exists yet?

The fixed expiration like expireAfterWrite means there is a duration the cache knows about and schedules with. The variable expiration like expireAfter(Expiry) means that there is logic that the cache calls with the key/value to determine the schedule. That is logic, e.g. Expiry.writing((key, value) -> (key % 1 == 0) ? Duration.ofMinutes(1) : Duration.ofMinutes(5)). There isn't a way to know for an absent entry, and since its your logic then you can call that if reasonable. I'm not sure about the Spring side which might make that harder.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ben-manes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants