-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JCache: add active expiration when using ExpiryPolicy (fixes #265)
Previously, an JCache expiration was implemented as a fully lazy wrapper and relied on size eviction to eventually discard the entry if not accessed again. This matched the implementations by the spec authors. However, JSR-107 doesn't offer a standard configuration for setting a maximum size. This would allow an expiry-only cache to run out of memory due to the lack of cleanup. The authors assumed a size would have to be applied, and we followed their examples. Caffeine later added its own variable expiration. This is not fully compatible due to slight semantic issues. For example, JCache TCK asserts that inserting an entry with an immediate expiration duration is never actually inserted into the cache. That means evaluating the expiration time during a cache compute and returning a null mapping. Caffeine's logic will insert and immediately discard. This has the same effect, except callbacks for listener events receive the create and delete, whereas JCache requires that both are suppressed. This causes the integration to become difficult due to small lifecycle differences that the TCK asserts. Instead, we continue to use a lazy wrapper but more proactively clean up via Caffeine's native support. This is already an option if setting any of the native options explicitly. Now if none of the native settings are used, the adapter will default to use variable expiration that reads the wrapper's timestamp. This will allow the cache maintenance to discard the entry regardless of if a maximum size is set.
- Loading branch information
Showing
14 changed files
with
205 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.