question

JohnMclean-4399 avatar image
0 Votes"
JohnMclean-4399 asked shashishailaj edited

Touch a key in to keep it alive

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
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @johnmclean-4399,

Thanks for using Microsoft Q&A !!
I am checking on this one internally if this is possible in CosmosDb and get back to you.

Thanks
Saurabh

0 Votes 0 ·
SaurabhSharma-msft avatar image
0 Votes"
SaurabhSharma-msft answered

Hi @johnmclean-4399,

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


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

JohnMclean-4399 avatar image
1 Vote"
JohnMclean-4399 answered SaurabhSharma-msft edited

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
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@johnmclean-4399 yes, right. Also, Patch won’t save much/any RU/s. It will save from having to do another round trip if the etag doesn’t match but otherwise it wont. Please let us know in case you have any other questions on the same.

Thanks
Saurabh

0 Votes 0 ·