Back to problems

Design TTL Cache

Object-Oriented Programming · Apple · Medium

Build a TTL-Aware Cache Create a cache in which each stored item has a time-to-live (TTL). A value can be retrieved only during its valid interval after insertion; once that interval ends, the item is no longer available. Implement the TTLCache class: TTLCache() Creates an initially empty cache. void put(int currentTime, String key, int value, int ttl) Saves key -> value and sets its expiration to currentTime + ttl. Writing an existing key replaces both its value and its…

Checking your access…