Refreshes the value associated with key, unless another thread is already doing so. Returns the newly refreshed value associated with key if it was refreshed inline, or null if another thread is performing the refresh or if an error occurs during refresh.
(K key, int hash, CacheLoader<? super K, V> loader, boolean checkTime)
| 2469 | */ |
| 2470 | |
| 2471 | @Nullable |
| 2472 | V refresh(K key, int hash, CacheLoader<? super K, V> loader, boolean checkTime) { |
| 2473 | final LoadingValueReference<K, V> loadingValueReference = insertLoadingValueReference(key, hash, checkTime); |
| 2474 | if (loadingValueReference == null) { |
| 2475 | return null; |
| 2476 | } |
| 2477 | ListenableFuture<V> result = loadAsync(key, hash, loadingValueReference, loader); |
| 2478 | if (result.isDone()) { |
| 2479 | try { |
| 2480 | return Uninterruptibles.getUninterruptibly(result); |
| 2481 | } catch (Throwable t) { |
| 2482 | // don't let refresh exceptions propagate; error was already logged |
| 2483 | } |
| 2484 | } |
| 2485 | return null; |
| 2486 | } |
| 2487 | |
| 2488 | /** |
| 2489 | * Returns a newly inserted {@code LoadingValueReference}, or null if the live value reference |
no test coverage detected