Guava CacheLoader - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Guava CacheLoader class.

This code example shows how to use the following methods:load
    } 
 
    @Override 
    public V load(Object key) throws CacheException {
        try { 
            return loader.load((K) key);
        } catch (Exception e) {
            throw new CacheException(e);
        } 
    } 
 
    @Override 
    public Map<K, V> loadAll(Collection keys) {
        try { 
            return loader.loadAll(keys);
        } catch (Exception e) {
            throw new CacheException(e);
        } 
    } 
 
5
CodeRank
This code example shows how to use the following methods:load
    } 
 
    @Override 
    public V apply(K key) {
        try { 
            return cacheLoader.load(key);
        } catch (Exception e) {
            throw new RuntimeException(String.format("Could not apply cache on key %s", key), e);
        } 
    } 
 
    @Override 
    public void refresh(K key) {
        try { 
            getUnderlyingCache().put(key, cacheLoader.load(key));
        } catch (Exception e) {
            throw new RuntimeException(String.format("Could not refresh value for key %s", key), e);
        } 
    } 
} 
4
CodeRank
This code example shows how to use the following methods:load
            this.cacheLoader = cacheLoader;
        } 
 
        @Override 
        public V call() throws Exception {
            return cacheLoader.load(key);
        } 
    } 
 
    @Override 
    public V get(K key) throws ExecutionException {
        return get(key, new ValueLoaderFromCacheLoader(cacheLoader, key));
    } 
 
    @Override 
    public V getUnchecked(K key) {
        try { 
            return get(key, new ValueLoaderFromCacheLoader(cacheLoader, key));
        } catch (ExecutionException e) {
            throw new RuntimeException(e.getCause());
4
CodeRank
See Code Examples for Guava CacheLoader Methods: