Assume I want to cache the results of expensive method calls. These cache entries should have a different expiry duration (aka TTL). Is this possible with JCache if the entries are put into the same Cache instance?
I am aware that I can assign a different ExpiryPolicy to each cache. However I wonder if it's possible to assign a expiry duration individually to a CacheEntry.
Does JCache support this? If so I'd appreciate a link to a code example for this. The scope of this question is purely JCache without any implementation specific features.
Variable expiry per entry is not supported in JCache.
Background: It was initially planned that the methods for the ExpiryPolicy
have the entry as parameter. During the finalization of the standard this was removed, since there were concerns about additional overhead especially for distributed caches, which might need to transfer the entry data over the network before the expiry policy can be called.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With