ConcurrentCachepublic final class ConcurrentCache extends Object
Fields Summary |
---|
private final int | size | private final Map | eden | private final Map | longterm |
Constructors Summary |
---|
public ConcurrentCache(int size)
this.size = size;
this.eden = new ConcurrentHashMap<K,V>(size);
this.longterm = new WeakHashMap<K,V>(size);
|
Methods Summary |
---|
public V | get(K k)
V v = this.eden.get(k);
if (v == null) {
v = this.longterm.get(k);
if (v != null) {
this.eden.put(k, v);
}
}
return v;
| public void | put(K k, V v)
if (this.eden.size() >= size) {
this.longterm.putAll(this.eden);
this.eden.clear();
}
this.eden.put(k, v);
|
|