HotEntryCache will update Instants only once per second
Calling Instant.now() several hundred thousand times per second can be expensive. In my measurements >10% of the time spend when loading new data was spend calling Instant.now(). Fixed this by storing an Instant as static member and updating it periodically in a separate thread.
This commit is contained in:
@@ -71,7 +71,7 @@ public class TagsToFile implements AutoCloseable {
|
||||
public TagsToFile(final DataStore dataStore) {
|
||||
this.dataStore = dataStore;
|
||||
|
||||
writerCache = new HotEntryCache<>(Duration.ofSeconds(10));
|
||||
writerCache = new HotEntryCache<>(Duration.ofSeconds(10), "writerCache");
|
||||
writerCache.addListener(new RemovalListener(), EventType.EVICTED, EventType.REMOVED);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user