Touch a key in to keep it alive

John Mclean 26 Reputation points
2021-08-20T13:11:12.403+00:00

Hi, We're looking to migrate out on-prem Couchbase instance to Azure CosmosDb. I'm able to replicate all our current functionality with CosmosDb, all bar one.

Our Couchbase Key/Value documents are stored with a 20 minute expiry and we refresh this expiry with the Couchbase .Touch method every time the value is retrieved.

But I'm unable to find similar functionality with CosmosDb. Does anyone know if there's an ability of refreshing the TTL on a item without having to perform a new Save?

I'm conscious of the amount of RUs incurred on this additional upsert.

Thanks

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,912 questions
{count} votes

Accepted answer
  1. Saurabh Sharma 23,851 Reputation points Microsoft Employee Moderator
    2021-08-23T22:12:02.863+00:00

    Hi @John Mclean ,

    Here is update on your ask -
    TTL at the container level can be done without touching document(s) but there is no way to update the TTL on an individual document(s) without updating it.
    You could try look into Partial Document Update Preview. At minimum, it would simplify the converted code to little more than existing Touch() call. Also, I haven't dug myself enough to know if would also potentially affect RU cost and response time.

    Thanks
    Saurabh

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. John Mclean 26 Reputation points
    2021-08-24T13:22:46.513+00:00

    Thanks Saurabh,

    This is mush as I expected. However, the Partial document Update does look interesting. With this I could add a KeepAlive property and just iterate it with each Get.

    Thanks
    John

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.