@Nullable @Override public V get(@Nullable Object key) { if (key == null) { return null; } int hash = hash(key); return segmentFor(hash).get(key, hash); }
@Override public boolean remove(@Nullable Object key, @Nullable Object value) { if (key == null || value == null) { return false; } int hash = hash(key); return segmentFor(hash).remove(key, hash, value); }
@Nullable @Override public V remove(@Nullable Object key) { if (key == null) { return null; } int hash = hash(key); return segmentFor(hash).remove(key, hash); }
/** * Returns the internal entry for the specified key. The entry may be loading, expired, or * partially collected. */ @Nullable ReferenceEntry<K, V> getEntry(@Nullable Object key) { // does not impact recency ordering if (key == null) { return null; } int hash = hash(key); return segmentFor(hash).getEntry(key, hash); }
@Override public boolean containsKey(@Nullable Object key) { // does not impact recency ordering if (key == null) { return false; } int hash = hash(key); return segmentFor(hash).containsKey(key, hash); }
@Nullable V get(@Nonnull K key, @Nonnull CacheLoader<? super K, V> loader) throws ExecutionException { int hash = hash(Preconditions.checkNotNull(key)); return segmentFor(hash).get(key, hash, loader); }
@Nullable public V getIfPresent(@Nonnull Object key) { int hash = hash(Preconditions.checkNotNull(key)); V value = segmentFor(hash).get(key, hash); if (value == null) { } else { } return value; }
@Nullable @Override public V putIfAbsent(@Nonnull K key, @Nonnull V value) { Preconditions.checkNotNull(key); Preconditions.checkNotNull(value); int hash = hash(key); return segmentFor(hash).put(key, hash, value, true); }
@Nullable @Override public V put(@Nonnull K key, @Nonnull V value) { Preconditions.checkNotNull(key); Preconditions.checkNotNull(value); int hash = hash(key); return segmentFor(hash).put(key, hash, value, false); }
@Override public boolean replace(@Nonnull K key, @Nullable V oldValue, @Nonnull V newValue) { Preconditions.checkNotNull(key); Preconditions.checkNotNull(newValue); if (oldValue == null) { return false; } int hash = hash(key); return segmentFor(hash).replace(key, hash, oldValue, newValue); }
@Nullable @Override public V replace(@Nonnull K key, @Nonnull V value) { Preconditions.checkNotNull(key); Preconditions.checkNotNull(value); int hash = hash(key); return segmentFor(hash).replace(key, hash, value); }
void refresh(@Nonnull K key) { int hash = hash(Preconditions.checkNotNull(key)); segmentFor(hash).refresh(key, hash, defaultLoader, false); }