Lines Matching refs:key
39 * Returns the value for {@code key} if it exists in the cache or can be
44 public final V get(K key) {
45 if (key == null) {
46 throw new NullPointerException("key == null");
51 result = map.get(key);
58 result = create(key);
61 // NOTE: Another thread might have already inserted a value for |key| into the map.
67 map.put(key, result);
76 * Caches {@code value} for {@code key}. The value is moved to the head of
79 * @return the previous value mapped by {@code key}. Although that entry is
82 public synchronized final V put(K key, V value) {
83 if (key == null) {
84 throw new NullPointerException("key == null");
89 V previous = map.put(key, value);
98 K key = toEvict.getKey();
100 map.remove(key);
102 entryEvicted(key, value);
110 protected void entryEvicted(K key, V value) {}
113 * Called after a cache miss to compute a value for the corresponding key.
117 protected V create(K key) {