PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Software Engineering Fundamentals/Bytedance

Add TTL to an LRU cache

Last updated: Apr 16, 2026

Quick Overview

This question evaluates a candidate's understanding of cache design, LRU eviction policies, time-to-live (TTL) semantics, appropriate data structures, time complexity reasoning, and concurrency control.

  • hard
  • Bytedance
  • Software Engineering Fundamentals
  • Software Engineer

Add TTL to an LRU cache

Company: Bytedance

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: hard

Interview Round: Onsite

Design an in-memory LRU cache and explain how to extend it with TTL support. Requirements: - `get(key)` returns the value if the key exists and has not expired; otherwise it returns a cache miss. - `put(key, value, ttl)` inserts or updates an entry with an expiration time. - When capacity is exceeded, evict the least recently used item. - Expired items should never be returned, and the design should explain how they are removed. - Discuss the data structures, time complexity, cleanup strategy, and concurrency considerations.

Quick Answer: This question evaluates a candidate's understanding of cache design, LRU eviction policies, time-to-live (TTL) semantics, appropriate data structures, time complexity reasoning, and concurrency control.

Related Interview Questions

  • Explain Backend Infrastructure Fundamentals - Bytedance
  • Explain Backend Fundamentals and AI Tooling - Bytedance (hard)
  • How do you assess database system stability? - Bytedance (medium)
  • How to triage slow service alerts - Bytedance (hard)
  • How would you troubleshoot Linux services? - Bytedance (medium)
Bytedance logo
Bytedance
Mar 10, 2026, 12:00 AM
Software Engineer
Onsite
Software Engineering Fundamentals
0
0

Design an in-memory LRU cache and explain how to extend it with TTL support.

Requirements:

  • get(key) returns the value if the key exists and has not expired; otherwise it returns a cache miss.
  • put(key, value, ttl) inserts or updates an entry with an expiration time.
  • When capacity is exceeded, evict the least recently used item.
  • Expired items should never be returned, and the design should explain how they are removed.
  • Discuss the data structures, time complexity, cleanup strategy, and concurrency considerations.

Solution

Show

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Software Engineering Fundamentals•More Bytedance•More Software Engineer•Bytedance Software Engineer•Bytedance Software Engineering Fundamentals•Software Engineer Software Engineering Fundamentals
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.