use guava's cache as implementation for the HotEntryCache
My own implementation was faster, but was not able to implement a size limitation.
This commit is contained in:
@@ -13,9 +13,7 @@ import org.lucares.pdb.datastore.ReadException;
|
||||
import org.lucares.pdb.datastore.WriteException;
|
||||
import org.lucares.pdb.datastore.internal.DataStore;
|
||||
import org.lucares.utils.cache.HotEntryCache;
|
||||
import org.lucares.utils.cache.HotEntryCache.Event;
|
||||
import org.lucares.utils.cache.HotEntryCache.EventListener;
|
||||
import org.lucares.utils.cache.HotEntryCache.EventType;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -65,8 +63,8 @@ public class TagsToFile implements AutoCloseable {
|
||||
private final static class RemovalListener implements EventListener<CacheKey, PdbWriter> {
|
||||
|
||||
@Override
|
||||
public void onEvent(final Event<CacheKey, PdbWriter> event) {
|
||||
event.getValue().close();
|
||||
public void evicted(final CacheKey key, final PdbWriter value) {
|
||||
value.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,8 +74,8 @@ public class TagsToFile implements AutoCloseable {
|
||||
public TagsToFile(final DataStore dataStore) {
|
||||
this.dataStore = dataStore;
|
||||
|
||||
writerCache = new HotEntryCache<>(Duration.ofSeconds(10), "writerCache");
|
||||
writerCache.addListener(new RemovalListener(), EventType.EVICTED, EventType.REMOVED);
|
||||
writerCache = new HotEntryCache<>(Duration.ofSeconds(10), 1000);
|
||||
writerCache.addListener(new RemovalListener());
|
||||
}
|
||||
|
||||
public List<PdbFile> getFilesForQuery(final String query) {
|
||||
|
||||
Reference in New Issue
Block a user