Document expiry more than 30 days

I am trying to expire my documents in 7 years. But when I check the expiration which I set when upserting the document, it don’t give me a right milliseconds.

Here is what I tried so far,

var totalSeconds = (DateTime.UtcNow.AddYears(7) - DateTime.UnixEpoch).TotalSeconds;
var expiryTimestamp = TimeSpan.FromSeconds(some)

IOperationResult<dynamic> result = await _bucket.UpsertAsync(docId, data, expiryTimestamp )

Upon checking in the metadata in web console for expiration, it is giving me 3422993998 (Feb, 09, 1970)milliseconds.

The second approach I tried is this:

var expiry = (DateTime.UtcNow.AddYears(7) - DateTime.UnixEpoch).TotalMilliseconds;
var doc = new Document<dynamic>{ Id = docId, Expiration= expiry, Content=data }

This approach also didn’t work and also gives me same result as 1st approach. . Can anyone help understand what am I doing wrong here?

Thank you

Hi @nick2345,

I want to try and reproduce this but I’m seeing a couple issues with the code.

  1. In the first example, there is a “some” variable mentioned. I assume this is supposed to be “totalSeconds” instead?

  2. In the second example, you’re setting “Expiration” on the Document, but there is no “Expiration”, there is just “Expiry”.

Just trying to figure out if these are typos or maybe you’re on a much older version? Can you verify which version of the SDK that you are using (and which version of Couchbase Server while you’re at it)?