/** * Removes an entry from the cache. * * @return The removed entry */ public VALUE remove(KEY key) { return getValueForRemoved(values.remove(key)); }
/** * Removes an entry from the cache. * * @return The removed entry */ public VALUE remove(KEY key) { return getValueForRemoved(values.remove(key)); }
/** Stores an new entry in the cache. */ public VALUE put(KEY key, VALUE object) { CacheEntry<VALUE> entry; if (referenceType == ReferenceType.WEAK) { entry = new CacheEntry<>(new WeakReference<>(object), null); } else if (referenceType == ReferenceType.SOFT) { entry = new CacheEntry<>(new SoftReference<>(object), null); } else { entry = new CacheEntry<>(null, object); } countPutCountSinceEviction++; countPut++; if (isExpiring && nextCleanUpTimestamp == 0) { nextCleanUpTimestamp = System.currentTimeMillis() + expirationMillis + 1; } CacheEntry<VALUE> oldEntry; synchronized (this) { if (values.size() >= maxSize) { evictToTargetSize(maxSize - 1); } oldEntry = values.put(key, entry); } return getValueForRemoved(oldEntry); }
/** Stores an new entry in the cache. */ public VALUE put(KEY key, VALUE object) { CacheEntry<VALUE> entry; if (referenceType == ReferenceType.WEAK) { entry = new CacheEntry<>(new WeakReference<>(object), null); } else if (referenceType == ReferenceType.SOFT) { entry = new CacheEntry<>(new SoftReference<>(object), null); } else { entry = new CacheEntry<>(null, object); } countPutCountSinceEviction++; countPut++; if (isExpiring && nextCleanUpTimestamp == 0) { nextCleanUpTimestamp = System.currentTimeMillis() + expirationMillis + 1; } CacheEntry<VALUE> oldEntry; synchronized (this) { if (values.size() >= maxSize) { evictToTargetSize(maxSize - 1); } oldEntry = values.put(key, entry); } return getValueForRemoved(oldEntry); }
/** * Removes an entry from the cache. * * @return The removed entry */ public VALUE remove(KEY key) { return getValueForRemoved(values.remove(key)); }
/** * Removes an entry from the cache. * * @return The removed entry */ public VALUE remove(KEY key) { return getValueForRemoved(values.remove(key)); }
/** Stores an new entry in the cache. */ public VALUE put(KEY key, VALUE object) { CacheEntry<VALUE> entry; if (referenceType == ReferenceType.WEAK) { entry = new CacheEntry<>(new WeakReference<>(object), null); } else if (referenceType == ReferenceType.SOFT) { entry = new CacheEntry<>(new SoftReference<>(object), null); } else { entry = new CacheEntry<>(null, object); } countPutCountSinceEviction++; countPut++; if (isExpiring && nextCleanUpTimestamp == 0) { nextCleanUpTimestamp = System.currentTimeMillis() + expirationMillis + 1; } CacheEntry<VALUE> oldEntry; synchronized (this) { if (values.size() >= maxSize) { evictToTargetSize(maxSize - 1); } oldEntry = values.put(key, entry); } return getValueForRemoved(oldEntry); }
/** Stores an new entry in the cache. */ public VALUE put(KEY key, VALUE object) { CacheEntry<VALUE> entry; if (referenceType == ReferenceType.WEAK) { entry = new CacheEntry<>(new WeakReference<>(object), null); } else if (referenceType == ReferenceType.SOFT) { entry = new CacheEntry<>(new SoftReference<>(object), null); } else { entry = new CacheEntry<>(null, object); } countPutCountSinceEviction++; countPut++; if (isExpiring && nextCleanUpTimestamp == 0) { nextCleanUpTimestamp = System.currentTimeMillis() + expirationMillis + 1; } CacheEntry<VALUE> oldEntry; synchronized (this) { if (values.size() >= maxSize) { evictToTargetSize(maxSize - 1); } oldEntry = values.put(key, entry); } return getValueForRemoved(oldEntry); }