Insert document confirmation best practice

This may be a very stupid question, but how I can be sure a document was inserted in the DB other than doing a document get?

when I do an insert document, I receive this response:

Couchbase\StoreResultImpl Object
(
    [cas:Couchbase\StoreResultImpl:private] => AAAoBBUkPhY=
    [expiry:Couchbase\StoreResultImpl:private] => 
    [key:Couchbase\StoreResultImpl:private] => p:102a783e-8691-43d8-92bb-d7f5d18f7bbc
    [status:Couchbase\StoreResultImpl:private] => 0
    [err_ctx:Couchbase\StoreResultImpl:private] => 
    [err_ref:Couchbase\StoreResultImpl:private] => 
    [mutation_token:Couchbase\StoreResultImpl:private] => Couchbase\MutationTokenImpl Object
        (
            [partition_id:Couchbase\MutationTokenImpl:private] => 9
            [partition_uuid:Couchbase\MutationTokenImpl:private] => sO5guqhVAAA=
            [sequence_number:Couchbase\MutationTokenImpl:private] => AwAAAAAAAAA=
            [bucket_name:Couchbase\MutationTokenImpl:private] => app
        )

    [is_stored:Couchbase\StoreResultImpl:private] => 
    [num_persisted:Couchbase\StoreResultImpl:private] => 
    [num_replicated:Couchbase\StoreResultImpl:private] => 
)

which value from all these can confirm the operation was 100% successful. All of these seems to be private, so not sure I will be able to access any.

I know if the document exists I get an exception \Couchase\KeyExistsException but it doesn’t make sense to do two inserts to get an exception.

I could not find any example of how to do this correctly and It is hard to simulate all the possibilities in which the DB would fail.

You see the cas() property, which is assigned by the server and changes every time the document is being mutated, also there is mutationToken() which might be used to ensure that indexes caught up to this mutation, when doing queries. Both values present for successful mutation.

Also you can set durabilityLevel() in the options when you do mutation, if you want also wait until the value will be actually written on disk and replicated. https://docs.couchbase.com/sdk-api/couchbase-php-client-3.0.3/classes/Couchbase-DurabilityLevel.html

Thanks @avsej

so, what you are saying is that the best way to do it is somethink like this?

try {
      $result = couchbase insert document;
         if (!is_null($result->cas()))
               {
                    return true;
                }
    }
     catch (Couchbase\KeyExistsException $err)  //KeyExistsException
    {
          return false;
     }

      return false;

Getting the cas, would not slow things down?

No, cas already populated in the object.