Time to Live (TTL)

From Ilianko

← Back to DP-420 Terminology Reference

Category: Data Modeling & Partitioning

Summary: Container/item setting that automatically deletes items after a set time.

Overview

Time to Live (TTL) is a container (and optionally per-item) setting in Azure Cosmos DB that automatically deletes items after a specified number of seconds have elapsed since their last modification. TTL is commonly used to automatically expire transient data such as session state, caches, or logs, without requiring custom deletion logic.

More Info & Links

DP-420 Style Practice Questions

Q1. What does configuring Time to Live (TTL) on an Azure Cosmos DB container accomplish?

  • A. Automatically deletes items after a specified time since their last modification
  • B. Automatically compresses old documents
  • C. Automatically archives items to a secondary region
  • D. Automatically re-indexes the container nightly

Q2. Which scenario is a good candidate for using TTL?

  • A. Expiring session state or cache data that is only relevant for a limited time
  • B. Storing permanent financial transaction records
  • C. Storing reference data that should never expire
  • D. Storing the container's indexing policy

Answer Key

Answers are listed at the very end so you can attempt the questions first.

  • Q1 (Time to Live (TTL)): A. Automatically deletes items after a specified time since their last modification — TTL enables automatic expiration/deletion of items after a set number of seconds.
  • Q2 (Time to Live (TTL)): A. Expiring session state or cache data that is only relevant for a limited time — TTL suits transient data like sessions or caches that should automatically expire, not permanent records.

DP-420: Designing and Implementing Cloud-Native Applications Using Microsoft Azure Cosmos DB — term detail page