Azure-docs: Can you use Time to Live?

Created on 13 Jul 2020  Â·  4Comments  Â·  Source: MicrosoftDocs/azure-docs

Can you test the _time to live_ functionality with the emulator?


Document details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Pri2 cosmos-dsvc cxp product-question triaged

All 4 comments

@garfbradaz Thank you for the feedback. We are actively investigating and will get back to you soon.

@garfbradaz There are couple of ways you can test TTL functionality with Emulator:

  1. You need to set the TTL at the Container or Item level. Please refer to Link. I set it up at container level with 120 seconds as shown in below screenshot:

image

Post 120 seconds, running query in Data Explorer will not return the document. Refer to below screenshot:

image

  1. Another way is to set it through code using any SDK as mentioned in above article:
    // Create a new container with TTL enabled and a 90 day expiration await client.GetDatabase("database").CreateContainerAsync(new ContainerProperties { Id = "container", PartitionKeyPath = "/myPartitionKey", DefaultTimeToLive = 90 * 60 * 60 * 24; // expire all documents after 90 days });

Then create a document using the explorer/code and try fetching the record post 120 seconds. You must not receive documents older than 120 seconds.

This Article provides end to end steps for creation of MVC application using.NET SDK.

If there are further questions regarding this matter, please comment and we will gladly continue the discussion.

Thanks guys, i will take a look today.

@garfbradaz We are proceeding to close this issue.
If there are further questions regarding this matter, please comment and we will gladly continue the discussion.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

paulmarshall picture paulmarshall  Â·  3Comments

bityob picture bityob  Â·  3Comments

monteledwards picture monteledwards  Â·  3Comments

AronT-TLV picture AronT-TLV  Â·  3Comments

jamesgallagher-ie picture jamesgallagher-ie  Â·  3Comments