public V put(K key, final V value) { ReferenceKey refKey = this.keyFactory.createKey(this.queue, key); Callable<ReferenceValue<V>> call = new Callable() { public ReferenceValue<V> call() throws Exception { return valueFactory.createValue(queue, value); } }; FutureTask<ReferenceValue<V>> task = new FutureTask<ReferenceValue<V>>(call); Future f = this.cache.putIfAbsent(refKey, task); if (f == null) { f = task; task.run(); } return value; }
public V get(final Object key) { try { ReferenceKey<K> refKey = this.lookupFactory.createKey(this.queue, (K) key); Future<ReferenceValue<V>> f = this.cache.get(refKey); V value = dereferenceValue(f); refKey = this.keyFactory.createKey(this.queue, (K) key); f = this.cache.putIfAbsent(refKey, task); if (f == null) {
public V get(final Object key) { try { ReferenceKey<K> refKey = this.lookupFactory.createKey(this.queue, (K) key); ReferenceValue<V> refVal = this.cache.get(refKey); V value = dereferenceValue(refVal); if (value != null) { return value; } else { V created = create((K) key); refVal = valueFactory.createValue(queue, created); refKey = this.keyFactory.createKey(this.queue, (K) key); refVal = this.cache.putIfAbsent(refKey, refVal); value = dereferenceValue(refVal); if (value == null) { value = this.create((K) key); this.put((K) key, value); } return value; } } catch (Exception e) { if (e instanceof RuntimeException) throw (RuntimeException) e; throw new IllegalStateException(e); } }
public V get(final Object key) { try { ReferenceKey<K> refKey = this.lookupFactory.createKey(this.queue, (K) key); ReferenceValue<V> refVal = this.cache.get(refKey); V value = dereferenceValue(refVal); if (value != null) { return value; } else { V created = create((K) key); refVal = valueFactory.createValue(queue, created); refKey = this.keyFactory.createKey(this.queue, (K) key); refVal = this.cache.putIfAbsent(refKey, refVal); value = dereferenceValue(refVal); if (value == null) { value = this.create((K) key); this.put((K) key, value); } return value; } } catch (Exception e) { if (e instanceof RuntimeException) throw (RuntimeException) e; throw new IllegalStateException(e); } }
public V remove(Object key) { ReferenceKey<K> keyRef = this.lookupFactory.createKey(this.queue, key); return this.dereferenceValue(this.cache.remove(keyRef)); }
public V remove(Object key) { ReferenceKey<K> keyRef = this.lookupFactory.createKey(this.queue, key); return this.dereferenceValue(this.cache.remove(keyRef)); }
public V remove(Object key) { ReferenceKey<K> keyRef = this.lookupFactory.createKey(this.queue, key); return this.dereferenceValue(this.cache.remove(keyRef)); }
public ReferenceValue<V> call() throws Exception { V created = create((K) key); if (created != null) { return valueFactory.createValue(queue, created); } else { throw new NullPointerException("Value created was Null"); } } };
public V put(K key, final V value) { ReferenceKey refKey = this.keyFactory.createKey(this.queue, key); ReferenceValue<V> refVal = valueFactory.createValue(queue, value); refVal = this.cache.putIfAbsent(refKey, refVal); return value; }
public ReferenceValue<V> call() throws Exception { return valueFactory.createValue(queue, value); } };
public V put(K key, final V value) { ReferenceKey refKey = this.keyFactory.createKey(this.queue, key); ReferenceValue<V> refVal = valueFactory.createValue(queue, value); refVal = this.cache.putIfAbsent(refKey, refVal); return value; }