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
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:

  1. Data Structures: We will use a dictionary (has...

Submit Your Answer
Markdown supported

Related Questions