1

I would like to do upserts to Couchbase (version 6.5.1 build 6299) with locking. The problem is that the documentation of couchbase its selve seems incomplete.

The problem is that I can lock the file, and unlock but I don' t find how to use the Cas when upserting. As the documentation states (https://docs.couchbase.com/dotnet-sdk/3.0/howtos/kv-operations.html) I should to it as followed:

var result = await collection.InsertAsync("document-key", document,
    options =>
    {
        options.WithCas(12345);
        options.WithTimeout(TimeSpan.FromSeconds(5));
    }
);

When I tried this, I got the following error: "UpsertOptions does not contain a definition for WithCas"

Does anyone have any idea how I should manage?

2
  • The code says InsertAsync, but the rest of your question says Upsert. I don't think this is the problem, but I would suggest editing to make it clear which one you want. Commented Jul 22, 2020 at 19:48
  • 1
    Hi Kristof! The answer posted by Matthew Groves is correct. The operation you're looking for might be Replace (or ReplaceAsync) which does accept a CAS value. Commented Jul 23, 2020 at 18:26

1 Answer 1

1

Looks like the docs are a bit wrong right now. InsertAsync and UpsertAsync do not use CAS values.

My understanding is that in previous SDKs, the CAS value in insert/upsert was basically just ignored (set to 0) and only certain operations (like replace) actually passed the CAS along. So in SDK 3, this was corrected. You can no longer specify CAS, except for operations that actually use it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.