You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/cosmos-db/nosql/time-to-live.md
+15-13Lines changed: 15 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,14 +7,16 @@ ms.reviewer: mjbrown
7
7
ms.service: azure-cosmos-db
8
8
ms.subservice: nosql
9
9
ms.topic: conceptual
10
-
ms.date: 11/03/2023
10
+
ms.date: 08/08/2024
11
11
---
12
+
12
13
# Time to Live (TTL) in Azure Cosmos DB
14
+
13
15
[!INCLUDE[NoSQL](../includes/appliesto-nosql.md)]
14
16
15
-
With **Time to Live** or TTL, Azure Cosmos DB deletes items automatically from a container after a certain time period. By default, you can set time to live at the container level and override the value on a per-item basis. After you set the TTL at a container or at an item level, Azure Cosmos DB will automatically remove these items after the time period, since the time they were last modified. Time to live value is configured in seconds. When you configure TTL, the system automatically deletes the expired items based on the TTL value, without needing a delete operation explicitly issued by the client application. The maximum value for TTL is 2147483647 seconds, the approximate equivalent of 24,855 days or 68 years.
17
+
With **Time to Live** or TTL, Azure Cosmos DB deletes items automatically from a container after a certain time period. By default, you can set time to live at the container level and override the value on a per-item basis. After you set the TTL at a container or at an item level, Azure Cosmos DB will automatically remove these items after the time period, since the time they were last modified. Time to live value is configured in seconds. When you configure TTL, the system automatically deletes the expired items based on the TTL value, without needing a delete operation explicitly issued by the client application. The maximum value for TTL is 2,147,483,647 seconds, the approximate equivalent of 24,855 days or 68 years.
16
18
17
-
Deletion of expired items is a background task that consumes left-over [Request Units](../request-units.md) that haven't been consumed by user requests. Even after the TTL expires, if the container is overloaded with requests and if there aren't enough RUs available, the data deletion is delayed. Data is deleted once there are enough RUs available to perform the delete operation. Though the data deletion is delayed, data isn't returned by any queries (by any API) after the TTL expires.
19
+
Deletion of expired items is a background task that consumes left-over [Request Units](../request-units.md) that haven't been consumed by user requests. Even after the TTL expires, if the container is overloaded with requests and if there aren't enough request units (RUs) available, the data deletion is delayed. Data is deleted once there are enough RUs available to perform the delete operation. Though the data deletion is delayed, data isn't returned by any queries (by any API) after the TTL expires.
18
20
19
21
> [!NOTE]
20
22
> This content is related to Azure Cosmos DB transactional store TTL. If you are looking for analytical store TTL, that enables NoETL HTAP scenarios through [Azure Synapse Link](../synapse-link.md), please click [here](../analytical-store-introduction.md#analytical-ttl).
@@ -27,9 +29,9 @@ The time to live value is set in seconds, and is interpreted as a delta from the
27
29
28
30
- If missing (or set to null), items aren't expired automatically.
29
31
30
-
- If present and the value is set to "-1", it's equal to infinity, and items don’t expire by default.
32
+
- If present and the value is set to *"-1,"* it's equal to infinity, and items don’t expire by default.
31
33
32
-
- If present and the value is set to some *nonzero* number *"n"* – items will expire *"n"* seconds after their last modified time.
34
+
- If present and the value is set to some *nonzero* number *"n,"* items will expire *"n"* seconds after their last modified time.
33
35
34
36
2.**Time to Live on an item** (set using `ttl`):
35
37
@@ -58,29 +60,29 @@ TTL on container is set to null (DefaultTimeToLive = null)
58
60
59
61
|TTL on item| Result|
60
62
|---|---|
61
-
|ttl property missing |TTL is disabled. The item will never expire (default).|
62
-
|ttl = -1|TTL is disabled. The item will never expire.|
63
-
|ttl = 2000|TTL is disabled. The item will never expire.|
63
+
|ttl property missing |TTL is disabled. The item never expires (default).|
64
+
|ttl = -1|TTL is disabled. The item never expires.|
65
+
|ttl = 2000|TTL is disabled. The item never expires.|
64
66
65
67
### Example 2
66
68
67
69
TTL on container is set to -1 (DefaultTimeToLive = -1)
68
70
69
71
|TTL on item| Result|
70
72
|---|---|
71
-
|ttl property missing |TTL is enabled. The item will never expire (default).|
72
-
|ttl = -1|TTL is enabled. The item will never expire.|
73
-
|ttl = 2000|TTL is enabled. The item will expire after 2000 seconds.|
73
+
|ttl property missing |TTL is enabled. The item never expires (default).|
74
+
|ttl = -1|TTL is enabled. The item never expires.|
75
+
|ttl = 2000|TTL is enabled. The item expires after 2,000 seconds.|
74
76
75
77
### Example 3
76
78
77
79
TTL on container is set to 1000 (DefaultTimeToLive = 1000)
78
80
79
81
|TTL on item| Result|
80
82
|---|---|
81
-
|ttl property missing |TTL is enabled. The item will expire after 1000 seconds (default).|
83
+
|ttl property missing |TTL is enabled. The item will expire after 1,000 seconds (default).|
82
84
|ttl = -1|TTL is enabled. The item will never expire.|
83
-
|ttl = 2000|TTL is enabled. The item will expire after 2000 seconds.|
85
+
|ttl = 2000|TTL is enabled. The item will expire after 2,000 seconds.|
0 commit comments