Skip to content
This repository has been archived by the owner on Jan 24, 2022. It is now read-only.

Commit

Permalink
change: Synchronize de-duplication cache
Browse files Browse the repository at this point in the history
  • Loading branch information
jellysquid3 committed Jun 18, 2021
1 parent 98b8d57 commit 905e7b0
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,22 @@ public synchronized T deduplicate(T item) {
return this.cache.addOrGet(item);
}

public void clearCache() {
this.cache.clear();
public synchronized void clearCache() {
this.attemptedInsertions = 0;

this.cache.clear();
}

public int getSize() {
public synchronized int getSize() {
return this.cache.size();
}

public int getDeduplicatedCount() {
public synchronized int getDeduplicatedCount() {
return this.attemptedInsertions - this.cache.size();
}

@Override
public String toString() {
public synchronized String toString() {
return String.format("DeduplicationCache ( %d de-duplicated, %d entries )",
this.getDeduplicatedCount(), this.getSize());
}
Expand Down

0 comments on commit 905e7b0

Please sign in to comment.