@Override public V load(K key) throws Exception { return loader.load(key); }
@Override public Map<K, V> loadAll(Iterable<? extends K> keys) throws Exception { return loader.loadAll(keys); } };
/** * Acquire LogSegment's monitor so that there is no concurrent loading. */ synchronized LogEntryProto loadCache(LogRecord record) throws RaftLogIOException { LogEntryProto entry = entryCache.get(record.getTermIndex()); if (entry != null) { return entry; } try { entry = cacheLoader.load(record); hasEntryCache = true; return entry; } catch (Exception e) { throw new RaftLogIOException(e); } }
try { @SuppressWarnings("unchecked") // safe since all keys extend K Map<K, V> map = (Map<K, V>) loader.loadAll(keys); result = map; success = true;
/** * Computes or retrieves a replacement value corresponding to an already-cached {@code key}. This * method is called when an existing cache entry is refreshed by {@link * CacheBuilder#refreshAfterWrite}, or through a call to {@link LoadingCache#refresh}. * * <p>This implementation synchronously delegates to {@link #load}. It is recommended that it be * overridden with an asynchronous implementation when using {@link * CacheBuilder#refreshAfterWrite}. * * <p><b>Note:</b> <i>all exceptions thrown by this method will be logged and then swallowed</i>. * * @param key the non-null key whose value should be loaded * @param oldValue the non-null old value corresponding to {@code key} * @return the future new value associated with {@code key}; <b>must not be null, must not return * null</b> * @throws Exception if unable to reload the result * @throws InterruptedException if this method is interrupted. {@code InterruptedException} is * treated like any other {@code Exception} in all respects except that, when it is caught, * the thread's interrupt status is set * @since 11.0 */ @GwtIncompatible // Futures public ListenableFuture<V> reload(K key, V oldValue) throws Exception { checkNotNull(key); checkNotNull(oldValue); return Futures.immediateFuture(load(key)); }