Skip to content

Instantly share code, notes, and snippets.

@dakshj
dakshj / TtlHashMap.java
Last active April 26, 2025 22:32 — forked from joelittlejohn/TtlHashMap.java
A passive TTL hash map, that expires and removes values if they are older than some time-to-live. I have only proved this correct, not tried it ;)
package com.example;
import static java.util.Collections.*;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;