Build a thread-safe bounded cache supporting O(1) LRU eviction when full AND automatic time-to-live (TTL) expiration per entry—made cleanly deterministic to test by injecting java.time.Clock instead of hardcoding Instant.now()!
More lessons in Complete Core Java