Auto Expiring Cache
Netflix interview questions · Hard · Coding round · 6 tests
Implement an in-memory cache with automatic expiration. Each key maps to a string value plus a time-to-live in milliseconds. Once an entry expires, reads should behave as if that key no longer exists.
Interface
class AutoExpiringCache {
set(key: string, value: string, ttlMs: number): void;
get(key: string): string | null;
has(key: string): boolean;
count(): number;
}
Rules
Run your code with Ctrl+Enter to see results.