-
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.
When an entry is eligible for refresh, only one thread should block to schedule it. Previously all readers would block on a map computeIfAbsent operation to obtain the future. While this allows refreshes to be linearizable, it adds a small and unnecessary synchronization point. The change restores the non-blocking behavior of v2.x, while keeping the improvements of v3's rewrite. The write timestamp is CAS'd as a soft lock to allow subsequent readers to skip attempting to refresh. The least significant bit is used as a flag for locking, causing the timestamp to be off by 1ns from the ideal value. (Thanks @Maaartinus for suggesting this idea in #282 (comment)) Also restored from v2 is to suppress and log exceptions if the cache loader fails when producing the refresh future. The inspections to obtain an entry's age were improved, such as not resurrecting an expired entry.
- Loading branch information
Showing
9 changed files
with
275 additions
and
82 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
Oops, something went wrong.