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
Coding & Algorithms
Software Engineer
Wiz
December 9, 2025
Software Engineer
Technical Phone Screen
Coding & Algorithms
Medium

10

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
LRU cache implementation
Doubly linked list + hash map
TTL expiration strategies
Multi-tenant resource isolation
Data structure design
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. 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 Problems
Sample Answer
Implementation

```python import time from collections import OrderedDict, defaultdict class TenantLRUCache: def __init__(self, global_capacity, per_tenant_capac...

Design Tradeoffs

Per-tenant eviction (_evict_tenant_lru) is O(n) in worst case because we scan for the tenant's oldest entry. For production, maintain a per-tenant LRU...


Submit Your Answer
Markdown supported

Related Questions