/** * Refresh the cache. Any existing entries in the cache will be re-fetched after it is cleared. */ public void refresh() { synchronized (map) { Set<KEY> contents = new HashSet<>(map.keySet()); clear(); for (KEY key : contents) { internalGet(key); } } }
/** * Get value for specified key. If not in cache, will call subclass's fetch method and load into * cache. * * @param key The key. * @return The associated value. */ public VALUE get(KEY key) { return isCached(key) ? map.get(key).getObject() : internalGet(key); }