/** * Looks up an entry. creating it if not found. */ @Override public Element get(final Object key) throws LockTimeoutException { Element element = super.get(key); if (element == null) { try { // Value not cached - fetch it Object value = factory.createEntry(key); element = makeAndCheckElement(key, value); } catch (final Throwable throwable) { // Could not fetch - Ditch the entry from the cache and rethrow // release the lock you acquired element = new Element(key, null); throw new CacheException("Could not fetch object for cache entry with key \"" + key + "\".", throwable); } finally { put(element); } } return element; }
public void put(K key, V value) { self.put(new Element(key, value)); }
public void put(K key, V value) { self.put(new Element(key, value)); }
/** * Looks up an entry. creating it if not found. */ @Override public Element get(final Object key) throws LockTimeoutException { Element element = super.get(key); if (element == null) { try { // Value not cached - fetch it Object value = factory.createEntry(key); element = makeAndCheckElement(key, value); } catch (final Throwable throwable) { // Could not fetch - Ditch the entry from the cache and rethrow // release the lock you acquired element = new Element(key, null); throw new CacheException("Could not fetch object for cache entry with key \"" + key + "\".", throwable); } finally { put(element); } } return element; }
/** * Looks up an entry. creating it if not found. */ @Override public Element get(final Object key) throws LockTimeoutException { Element element = super.get(key); if (element == null) { try { // Value not cached - fetch it Object value = factory.createEntry(key); element = makeAndCheckElement(key, value); } catch (final Throwable throwable) { // Could not fetch - Ditch the entry from the cache and rethrow // release the lock you acquired element = new Element(key, null); throw new CacheException("Could not fetch object for cache entry with key \"" + key + "\".", throwable); } finally { put(element); } } return element; }
/** * Looks up an entry. creating it if not found. */ @Override public Element get(final Object key) throws LockTimeoutException { Element element = super.get(key); if (element == null) { try { // Value not cached - fetch it Object value = factory.createEntry(key); element = makeAndCheckElement(key, value); } catch (final Throwable throwable) { // Could not fetch - Ditch the entry from the cache and rethrow // release the lock you acquired element = new Element(key, null); throw new CacheException("Could not fetch object for cache entry with key \"" + key + "\".", throwable); } finally { put(element); } } return element; }
public void run(){ if (e.getVersion() == signature){ // triple check try{ V newValue = getDirectly((K)e.getObjectKey()); if (newValue == null){ cache.remove(e.getObjectKey()); }else{ cache.put(new Element((K)e.getObjectKey(), newValue)); } }catch(Exception ex){ logger.warn("Failed to update the value associated with specified key '{}' in cache '{}'", e.getObjectKey(), cache.getName(), ex); } } } });