public synchronized boolean remove(final CacheKey key, final EncodedImage encodedImage) {
    Preconditions.checkNotNull(key);
    Preconditions.checkNotNull(encodedImage);
    Preconditions.checkArgument(EncodedImage.isValid(encodedImage));

    final EncodedImage oldValue = mMap.get(key);

    if (oldValue == null) {
      return false;
    }

    CloseableReference<PooledByteBuffer> oldRef = oldValue.getByteBufferRef();
    CloseableReference<PooledByteBuffer> ref = encodedImage.getByteBufferRef();
    try {
      if (oldRef == null || ref == null || oldRef.get() != ref.get()) {
        return false;
      }
      mMap.remove(key);
    } finally {
      CloseableReference.closeSafely(ref);
      CloseableReference.closeSafely(oldRef);
      EncodedImage.closeSafely(oldValue);
    }

    logStats();
    return true;
  }
Removes key-value from the StagingArea. Both key and value must match.

@param key
@param encodedImage value corresponding to key
@return true if item was removed
imagepipeline/src/main/java/com/facebook/imagepipeline/cache/StagingArea.java