Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

does JCache (JSR107) allow different expiry durations for different entries?

Tags:

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.

like image 637
Stefan Armbruster Avatar asked May 24 '16 08:05

Stefan Armbruster


1 Answers

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.

like image 119
cruftex Avatar answered Sep 28 '22 02:09

cruftex