You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there best practice to refresh synchronously?
refresh asynchronously is good in most cases, but I have some cases it needs to block to return until refresh is done.
The text was updated successfully, but these errors were encountered:
You might want #143, where LoadingCache#refresh would return CompletableFuture. Unfortunately that requires a major version bump since it changes the interface signature.
You might instead use asMap().computeIfPresent to perform the call synchronously. That would block other writers to that hashbin (~ per entry) but not block readers.
Another option is to use Caffeine.executor(Runnable::run) to perform any async logic directly on the caller's thread. In most cases this is okay, but if your code is expensive then it can add latency (e.g. some readers are penalized by performing the work).
Is there best practice to refresh synchronously?
refresh asynchronously is good in most cases, but I have some cases it needs to block to return until refresh is done.
The text was updated successfully, but these errors were encountered: