Skip to content

Instantly share code, notes, and snippets.

View GiuseppeMP's full-sized avatar
:copilot:
Making sure gas and oil don’t get lost on the way 🦖🦖

Giuseppe Matheus (Beppe) GiuseppeMP

:copilot:
Making sure gas and oil don’t get lost on the way 🦖🦖
View GitHub Profile
@GiuseppeMP
GiuseppeMP / SelfExpiringHashMap.java
Created February 8, 2017 11:00
SelfExpiringHashMap - a Java Map which entries expire automatically after a given time; it uses a DelayQueue internally.
import java.util.Collection;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.DelayQueue;
import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit;