public final boolean containsKey(@Nullable Object key) { return getIfCached(key) != null || backingMap.containsKey(key); }
public final boolean containsKey(@NullableDecl Object key) { return getIfCached(key) != null || backingMap.containsKey(key); }
public V get(@Nullable Object key) { V value = getIfCached(key); return (value != null) ? value : getWithoutCaching(key); }
public final boolean containsKey(@NullableDecl Object key) { return getIfCached(key) != null || backingMap.containsKey(key); }
@Override protected V getIfCached(@Nullable Object key) { V value = super.getIfCached(key); if (value != null) { return value; } // Store a local reference to the cache entry. If the backing map is immutable, this, // in combination with immutable cache entries, will ensure a thread-safe cache. CacheEntry<K, V> entry; // Check cache. We use == on purpose because it's cheaper and a cache miss is ok. entry = cacheEntry1; if (entry != null && entry.key == key) { return entry.value; } entry = cacheEntry2; if (entry != null && entry.key == key) { // Promote second cache entry to first so the access pattern // [K1, K2, K1, K3, K1, K4...] still hits the cache half the time. addToCache(entry); return entry.value; } return null; }
public V get(@NullableDecl Object key) { V value = getIfCached(key); return (value != null) ? value : getWithoutCaching(key); }
public V get(@NullableDecl Object key) { V value = getIfCached(key); return (value != null) ? value : getWithoutCaching(key); }
@Override protected V getIfCached(@NullableDecl Object key) { V value = super.getIfCached(key); if (value != null) { return value; } // Store a local reference to the cache entry. If the backing map is immutable, this, // in combination with immutable cache entries, will ensure a thread-safe cache. CacheEntry<K, V> entry; // Check cache. We use == on purpose because it's cheaper and a cache miss is ok. entry = cacheEntry1; if (entry != null && entry.key == key) { return entry.value; } entry = cacheEntry2; if (entry != null && entry.key == key) { // Promote second cache entry to first so the access pattern // [K1, K2, K1, K3, K1, K4...] still hits the cache half the time. addToCache(entry); return entry.value; } return null; }
@Override protected V getIfCached(@NullableDecl Object key) { V value = super.getIfCached(key); if (value != null) { return value; } // Store a local reference to the cache entry. If the backing map is immutable, this, // in combination with immutable cache entries, will ensure a thread-safe cache. CacheEntry<K, V> entry; // Check cache. We use == on purpose because it's cheaper and a cache miss is ok. entry = cacheEntry1; if (entry != null && entry.key == key) { return entry.value; } entry = cacheEntry2; if (entry != null && entry.key == key) { // Promote second cache entry to first so the access pattern // [K1, K2, K1, K3, K1, K4...] still hits the cache half the time. addToCache(entry); return entry.value; } return null; }
public final boolean containsKey(@Nullable Object key) { return getIfCached(key) != null || backingMap.containsKey(key); }
public final boolean containsKey(@NullableDecl Object key) { return getIfCached(key) != null || backingMap.containsKey(key); }
public V get(@Nullable Object key) { V value = getIfCached(key); return (value != null) ? value : getWithoutCaching(key); }
public V get(@NullableDecl Object key) { V value = getIfCached(key); return (value != null) ? value : getWithoutCaching(key); }
@Override protected V getIfCached(@NullableDecl Object key) { V value = super.getIfCached(key); if (value != null) { return value; } // Store a local reference to the cache entry. If the backing map is immutable, this, // in combination with immutable cache entries, will ensure a thread-safe cache. CacheEntry<K, V> entry; // Check cache. We use == on purpose because it's cheaper and a cache miss is ok. entry = cacheEntry1; if (entry != null && entry.key == key) { return entry.value; } entry = cacheEntry2; if (entry != null && entry.key == key) { // Promote second cache entry to first so the access pattern // [K1, K2, K1, K3, K1, K4...] still hits the cache half the time. addToCache(entry); return entry.value; } return null; }
@Override protected V getIfCached(@Nullable Object key) { V value = super.getIfCached(key); if (value != null) { return value; } // Store a local reference to the cache entry. If the backing map is immutable, this, // in combination with immutable cache entries, will ensure a thread-safe cache. CacheEntry<K, V> entry; // Check cache. We use == on purpose because it's cheaper and a cache miss is ok. entry = cacheEntry1; if (entry != null && entry.key == key) { return entry.value; } entry = cacheEntry2; if (entry != null && entry.key == key) { // Promote second cache entry to first so the access pattern // [K1, K2, K1, K3, K1, K4...] still hits the cache half the time. addToCache(entry); return entry.value; } return null; }