LRU Cache with TTL and Tenant Isolation
Last updated: December 9, 2025
Quick Overview
Implement an LRU cache that supports per-entry TTL expiration and tenant isolation, ensuring one tenant's cache usage cannot evict another tenant's entries.
Wiz
December 9, 202510
9
2,596 solved
Implement an LRU cache that supports per-entry TTL expiration and tenant isolation, ensuring one tenant's cache usage cannot evict another tenant's entries.
Caching is critical for Wiz's scanning performance, but in a multi-tenant system, cache design requires careful isolation. A large tenant's scan results should not evict a small tenant's cached data. This problem tests your ability to extend a classic data structure (LRU cache) with production requirements common in multi-tenant SaaS systems.
What the Interviewer Expects
- Implement a standard LRU cache with O(1) get/put operations
- Add TTL support with lazy expiration
- Implement per-tenant capacity limits within the global cache
- Handle edge cases: expired entries, tenant quota exceeded, empty cache
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you implement proactive TTL cleanup without impacting read latency?
- What if tenants have different cache priorities?
- How would you distribute this cache across multiple servers?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Problem Analysis
To effectively solve the problem of implementing an LRU Cache with TTL and Tenant Isolation, we need to recognize that the classic LRU cache structure, which typically uses a doubly linked list and a ...
Approach
The solution involves creating a class LRUCache that encapsulates the logic for managing the cache. Here’s how we can approach it step-by-step:
- Data Structures: We will use a dictionary (has...