Created
April 2, 2016 05:25
-
-
Save electrum/f77aa240ed3cdb70bcd5a1296b00642c to your computer and use it in GitHub Desktop.
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
import com.google.common.cache.CacheLoader; | |
public final class CacheLoaderUtil | |
{ | |
private CacheLoaderUtil() {} | |
public static <K, V> CacheLoader<K, V> cacheLoader(LoaderFunction<K, V> loader) | |
{ | |
return new CacheLoader<K, V>() | |
{ | |
@Override | |
public V load(K key) | |
throws Exception | |
{ | |
return loader.load(key); | |
} | |
}; | |
} | |
public interface LoaderFunction<K, V> | |
{ | |
V load(K key) | |
throws Exception; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment