Skip to content

Instantly share code, notes, and snippets.

@lukasz-zak
Last active December 24, 2015 14:58
Show Gist options
  • Save lukasz-zak/6816005 to your computer and use it in GitHub Desktop.
Save lukasz-zak/6816005 to your computer and use it in GitHub Desktop.
public class Cache<K, V> {
private Map<K, __________<V>> internalCache = new HashMap<>();
public V get(K key, ___________<V> calledWhenAbsent) throws Exception {
_____________<V> something = internalCache.get(key);
V result;
if (something == null || something.get() == null) {
result = calledWhenAbsent.call();
internalCache.put(key, new _____________<V>(result));
} else {
result = something.get();
}
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment