01Phone Screenwith Software EngineerTechnical45 minMedium
Interviewer: Software Engineer
I was asked to implement a TTL cache similar to the leetcode cache problem with the following methods:
set(key, value, duration) : sets a key-value along with it's expiration time
get(key) : returns the value associated with key if it's still valid
count(key) : returns unexpired key count
Follow-up:
There were follow-ups on scaling the cache system to handle scenarios where multiple clients are concurrently reading and writing to the cache, and possible performance optimizations
Tips:
Be sure to cover all possible edge cases and think aloud to clarify any assumptions