← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
Design and implement an in-memory key-value store that supports per-key TTL (time-to-live). The store must expose four operations: set(key, value, ttl) to insert or update a key with a relative TTL in seconds, get(key) to return the current value or None if the key is absent or expired, delete(key) to remove a key immediately and return True if it existed, and cleanup() (optional) to purge all expired keys. Expired entries must never be returned by get. You may use lazy expiration (check on read) or eager background expiration, but no external libraries are allowed. Concurrency is not required; focus on correctness, clarity, and O(1) average time for set, get, and delete.