Skip to content

Commit 65a5d70

Browse files
committed
Acrolinx bump
1 parent 71a9d1a commit 65a5d70

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

articles/cosmos-db/mongodb/time-to-live.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: MongoDB per-document TTL feature in Azure Cosmos DB
2+
title: MongoDB per-document time-to-live feature in Azure Cosmos DB
33
description: Learn how to set time to live value for documents using Azure Cosmos DB's API for MongoDB, to automatically purge them from the system after a period of time.
44
author: gahl-levy
55
ms.author: gahllevy
@@ -8,13 +8,13 @@ ms.subservice: mongodb
88
ms.devlang: csharp
99
# ms.devlang: csharp, java, javascript
1010
ms.topic: how-to
11-
ms.date: 02/16/2022
11+
ms.date: 06/05/2024
1212
ms.custom: devx-track-csharp
1313
---
1414
# Expire data with Azure Cosmos DB's API for MongoDB
1515
[!INCLUDE[MongoDB](../includes/appliesto-mongodb.md)]
1616

17-
Time-to-live (TTL) functionality allows the database to automatically expire data. Azure Cosmos DB's API for MongoDB utilizes Azure Cosmos DB's core TTL capabilities. Two modes are supported: setting a default TTL value on the whole collection, and setting individual TTL values for each document. The logic governing TTL indexes and per-document TTL values in Azure Cosmos DB's API for MongoDB is the [same as in Azure Cosmos DB](indexing.md).
17+
Time-to-live (TTL) functionality allows the database to automatically expire data. Azure Cosmos DB for MongoDB utilizes Azure Cosmos DB's core TTL capabilities. Two modes are supported: setting a default TTL value on the whole collection, and setting individual TTL values for each document. The logic governing TTL indexes and per-document TTL values in Azure Cosmos DB's API for MongoDB is the [same as in Azure Cosmos DB](indexing.md).
1818

1919
## TTL indexes
2020
To enable TTL universally on a collection, a ["TTL index" (time-to-live index)](indexing.md) needs to be created. The TTL index is an index on the `_ts` field with an "expireAfterSeconds" value.
@@ -24,7 +24,7 @@ MongoShell example:
2424
```
2525
globaldb:PRIMARY> db.coll.createIndex({"_ts":1}, {expireAfterSeconds: 10})
2626
```
27-
The command in the above example will create an index with TTL functionality.
27+
The command in the above example creates an index with TTL functionality.
2828

2929
The output of the command includes various metadata:
3030

@@ -38,7 +38,7 @@ The output of the command includes various metadata:
3838
}
3939
```
4040

41-
Once the index is created, the database will automatically delete any documents in that collection that have not been modified in the last 10 seconds.
41+
Once the index is created, the database will automatically delete any documents in that collection that haven't been modified in the last 10 seconds.
4242

4343
> [!NOTE]
4444
> `_ts` is an Azure Cosmos DB-specific field and is not accessible from MongoDB clients. It is a reserved (system) property that contains the timestamp of the document's last modification.
@@ -61,11 +61,11 @@ await collection.Indexes.CreateOneAsync(indexDefinition, options);
6161
```
6262

6363
## Set time to live value for a document
64-
Per-document TTL values are also supported. The document(s) must contain a root-level property "ttl" (lower-case), and a TTL index as described above must have been created for that collection. TTL values set on a document will override the collection's TTL value.
64+
Per-document TTL values are also supported. The document(s) must contain a root-level property "ttl" (lower-case), and a TTL index as described above must have been created for that collection. TTL values set on a document overrides the collection's TTL value.
6565

66-
The TTL value must be an int32. Alternatively, an int64 that fits in an int32, or a double with no decimal part that fits in an int32. Values for the TTL property that do not conform to these specifications are allowed but not treated as a meaningful document TTL value.
66+
The TTL value must be an int32. Alternatively, an int64 that fits in an int32, or a double with no decimal part that fits in an int32. Values for the TTL property that don't conform to these specifications are allowed but not treated as a meaningful document TTL value.
6767

68-
The TTL value for the document is optional; documents without a TTL value can be inserted into the collection. In this case, the collection's TTL value will be honored.
68+
The TTL value for the document is optional; documents without a TTL value can be inserted into the collection. In this case, the collection's TTL value is honored.
6969

7070
The following documents have valid TTL values. Once the documents are inserted, the document TTL values override the collection's TTL values. So, the documents will be removed after 20 seconds.
7171

@@ -75,7 +75,7 @@ globaldb:PRIMARY> db.coll.insert({id:1, location: "Paris", ttl: NumberInt(20)})
7575
globaldb:PRIMARY> db.coll.insert({id:1, location: "Paris", ttl: NumberLong(20)})
7676
```
7777

78-
The following documents have invalid TTL values. The documents will be inserted, but the document TTL value will not be honored. So, the documents will be removed after 10 seconds because of the collection's TTL value.
78+
The following documents have invalid TTL values. The documents are inserted, but the document TTL value won't be honored. So, the documents will be removed after 10 seconds because of the collection's TTL value.
7979

8080
```JavaScript
8181
globaldb:PRIMARY> db.coll.insert({id:1, location: "Paris", ttl: 20.5}) //TTL value contains non-zero decimal part.

0 commit comments

Comments
 (0)