public V getCachedValue(T key) { SofterReference<ConcurrentMap<T, V>> ref = myCache; ConcurrentMap<T, V> map = ref == null ? null : ref.get(); if (map == null) { myCache = new SofterReference<ConcurrentMap<T, V>>(map = ContainerUtil.newConcurrentMap()); } V value = map.get(key); if (value == null) { map.put(key, value = myValueProvider.fun(key)); } return value; }
public V getCachedValue(T key) { SofterReference<ConcurrentMap<T, V>> ref = myCache; ConcurrentMap<T, V> map = ref == null ? null : ref.get(); if (map == null) { myCache = new SofterReference<ConcurrentMap<T, V>>(map = new ConcurrentHashMap<T, V>()); } V value = map.get(key); if (value == null) { map.put(key, value = myValueProvider.fun(key)); } return value; }