fix wrong initialization of mem evictions counter

This commit is contained in:
kimchy 2011-04-14 19:13:14 +03:00
parent 1e84c439e5
commit 7874291c0e
2 changed files with 4 additions and 2 deletions

View File

@ -46,7 +46,7 @@ public class SoftFilterCache extends AbstractConcurrentMapFilterCache implements
private final TimeValue expire;
private final AtomicLong evictions = new AtomicLong();
private final AtomicLong memEvictions = new AtomicLong();
private AtomicLong memEvictions;
@Inject public SoftFilterCache(Index index, @IndexSettings Settings indexSettings) {
super(index, indexSettings);
@ -55,6 +55,7 @@ public class SoftFilterCache extends AbstractConcurrentMapFilterCache implements
}
@Override protected ConcurrentMap<Object, ReaderValue> buildCache() {
memEvictions = new AtomicLong(); // we need to init it here, since its called from the super constructor
// better to have soft on the whole ReaderValue, simpler on the GC to clean it
MapMaker mapMaker = new MapMaker().weakKeys().softValues();
mapMaker.evictionListener(new CacheMapEvictionListener(memEvictions));

View File

@ -46,7 +46,7 @@ public class WeakFilterCache extends AbstractConcurrentMapFilterCache implements
private final TimeValue expire;
private final AtomicLong evictions = new AtomicLong();
private final AtomicLong memEvictions = new AtomicLong();
private AtomicLong memEvictions;
@Inject public WeakFilterCache(Index index, @IndexSettings Settings indexSettings) {
super(index, indexSettings);
@ -55,6 +55,7 @@ public class WeakFilterCache extends AbstractConcurrentMapFilterCache implements
}
@Override protected ConcurrentMap<Object, ReaderValue> buildCache() {
memEvictions = new AtomicLong(); // we need to init it here, since its called from the super constructor
// better to have weak on the whole ReaderValue, simpler on the GC to clean it
MapMaker mapMaker = new MapMaker().weakKeys().softValues();
mapMaker.evictionListener(new CacheMapEvictionListener(memEvictions));