@Override public void put(K k, V v, Metadata metadata) { boolean l1Entry = false; if (metadata instanceof L1Metadata) { metadata = ((L1Metadata) metadata).metadata(); l1Entry = true; } InternalCacheEntry<K, V> e = entries.get(k); if (trace) { log.tracef( "Creating new ICE for writing. Existing=%s, metadata=%s, new value=%s", e, metadata, toStr(v)); } final InternalCacheEntry<K, V> copy; if (l1Entry) { copy = entryFactory.createL1(k, v, metadata); } else if (e != null) { copy = entryFactory.update(e, v, metadata); } else { // this is a brand-new entry copy = entryFactory.create(k, v, metadata); } if (trace) log.tracef("Store %s in container", copy); entries.compute( copy.getKey(), (key, entry) -> { activator.onUpdate(key, entry == null); return copy; }); }
public void put(Object k, Object v, EntryVersion version, long lifespan, long maxIdle) { InternalCacheEntry e = entries.get(k); if (e != null) { e.setValue(v); InternalCacheEntry original = e; e.setVersion(version); e = entryFactory.update(e, lifespan, maxIdle); // we have the same instance. So we need to reincarnate. if (original == e) { e.reincarnate(); } } else { // this is a brand-new entry e = entryFactory.create(k, v, version, lifespan, maxIdle); } entries.put(k, e); }