Skip to content

Commit

Permalink
enable ttl map cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
lovesh-ap committed Jan 17, 2025
1 parent 25e2db0 commit 108b457
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.newrelic.agent.security.intcodeagent.schedulers.SchedulerHelper;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;

public class TTLMap<K, V> {

Expand All @@ -18,6 +19,7 @@ public TTLMap(String id) {
public TTLMap(String id, long ttl) {
this.id = id;
TTL = ttl;
SchedulerHelper.getInstance().scheduleTTLMapCleanup(this::removeExpiredEntries, ttl, ttl, TimeUnit.MILLISECONDS, id);
}

public void put(K key, V value) {
Expand Down Expand Up @@ -48,7 +50,7 @@ public void shutdown() {
SchedulerHelper.getInstance().cancelTTLMapCleanup(this.id);
}

public boolean containsKey(K traceId) {
return map.containsKey(traceId);
}
public boolean containsKey(K traceId) {
return map.containsKey(traceId);
}
}

0 comments on commit 108b457

Please sign in to comment.