Set document expiration without getting the document

Hi guys,

I’m using Couchbase 4.0 and .NET SDK 2.3 and I’d like to be able to change the expiry date of a document without having to get the value and re-upsert it.

Currently:
var model = this.MethodToGetTheDocumentValue();
Bucket.Upsert(model.key, model, TimeSpan.FromDays(7));

Is there some way of doing this without getting the value, e.g:
Bucket.Upsert(model.key, TimeSpan.FromDays(7));

I am trying to change the expiry date of over 1000 documents when a user wants to mark something to be deleted, but this is obviously very slow if I need to get them each time.

@molexmat

Try using the Touch method instead of Upsert. It should do what you’re asking.

bucket.Touch(model.Key, TimeSpan.FromDays(7));

Brant

1 Like