user2770791
user2770791

Reputation: 603

Is there a way to set item level TTL(Time-To-Live) with CosmosDb utilizing the Table (azure-storage) client API?

I am using CosmosDb for a project, and was first trying the Document-db java SQL API. With that API I can set item-level TTLs right on the Document itself. Ex.

Document document = new Document(new Gson().toJson(testObject));
    document.setTimeToLive(10); // Time to live 10 seconds
    documentClient.createDocument(documentCollection.getSelfLink(), document, null,
        false).getResource();

However, I am also interested in using the Table API. I could not find anything in the documentation about setting item-level TTL. https://learn.microsoft.com/en-us/azure/cosmos-db/table-storage-how-to-use-java I am using https://github.com/Azure/azure-storage-java version 8.0.0 https://mvnrepository.com/artifact/com.microsoft.azure/azure-storage

Is it possible to do this, or at least set a server-side TTL for all items in a table? Thanks!

Upvotes: 1

Views: 1556

Answers (1)

Chris Anderson
Chris Anderson

Reputation: 8515

Today, Table API does not expose any TTL feature, so unfortunately you cannot use TTL with the Table API, even though Cosmos supports it under the covers.

Upvotes: 2

Related Questions