public void putAll(Map map) { synchronized (_cacheL2) { mergeIfL2NotEmpty(); // sepatare merge to avoid increasing L2 size too much // (it cannot be reallocated, it is final) merge(map); } }
retval = newInstance(key); if (retval != null) put(key, retval); mergeIfNeeded(); mergeIfNeeded();
public int size() { // Note: cannot simply return L1.size + L2.size // because there might be overlaping of keys synchronized (_cacheL2) { mergeIfL2NotEmpty(); return _cacheL1.size(); } }
private void mergeIfNeeded() { if (++_missCount >= _mergeThreshold) { merge(_cacheL2); } }
/** * If key is already in cacheL1, the new value will show with a delay, * since merge L2->L1 may not happen immediately. To force the merge sooner, * call <code>size()<code>. */ public Object put(Object key, Object value) { synchronized (_cacheL2) { _cacheL2.put(key, value); // not really a miss, but merge to avoid big increase in L2 size // (it cannot be reallocated, it is final) mergeIfNeeded(); } return value; }
retval = newInstance(key); if (retval != null) put(key, retval); mergeIfNeeded(); mergeIfNeeded();
public int size() { // Note: cannot simply return L1.size + L2.size // because there might be overlaping of keys synchronized (_cacheL2) { mergeIfL2NotEmpty(); return _cacheL1.size(); } }
private void mergeIfNeeded() { if (++_missCount >= _mergeThreshold) { merge(_cacheL2); } }
/** * If key is already in cacheL1, the new value will show with a delay, * since merge L2->L1 may not happen immediately. To force the merge sooner, * call <code>size()<code>. */ public Object put(Object key, Object value) { synchronized (_cacheL2) { _cacheL2.put(key, value); // not really a miss, but merge to avoid big increase in L2 size // (it cannot be reallocated, it is final) mergeIfNeeded(); } return value; }
retval = newInstance(key); if (retval != null) put(key, retval); mergeIfNeeded(); mergeIfNeeded();
public int size() { // Note: cannot simply return L1.size + L2.size // because there might be overlaping of keys synchronized (_cacheL2) { mergeIfL2NotEmpty(); return _cacheL1.size(); } }
public void putAll(Map map) { synchronized (_cacheL2) { mergeIfL2NotEmpty(); // sepatare merge to avoid increasing L2 size too much // (it cannot be reallocated, it is final) merge(map); } }
private void mergeIfNeeded() { if (++_missCount >= _mergeThreshold) { merge(_cacheL2); } }
/** * If key is already in cacheL1, the new value will show with a delay, * since merge L2->L1 may not happen immediately. To force the merge sooner, * call <code>size()<code>. */ public Object put(Object key, Object value) { synchronized (_cacheL2) { _cacheL2.put(key, value); // not really a miss, but merge to avoid big increase in L2 size // (it cannot be reallocated, it is final) mergeIfNeeded(); } return value; }
public Set entrySet() { synchronized (_cacheL2) { mergeIfL2NotEmpty(); return Collections.unmodifiableSet(_cacheL1.entrySet()); } }
public void putAll(Map map) { synchronized (_cacheL2) { mergeIfL2NotEmpty(); // sepatare merge to avoid increasing L2 size too much // (it cannot be reallocated, it is final) merge(map); } }
private void mergeIfL2NotEmpty() { if (!_cacheL2.isEmpty()) { merge(_cacheL2); } }
public Set keySet() { synchronized (_cacheL2) { mergeIfL2NotEmpty(); return Collections.unmodifiableSet(_cacheL1.keySet()); } }
private void mergeIfL2NotEmpty() { if (!_cacheL2.isEmpty()) { merge(_cacheL2); } }
public Collection values() { synchronized (_cacheL2) { mergeIfL2NotEmpty(); return Collections.unmodifiableCollection(_cacheL1.values()); } }