public async Task <IExistsResult> ExistsAsync(string id, ExistsOptions?options = null) { try { //sanity check for deferred bootstrapping errors _bucket.ThrowIfBootStrapFailed(); //Get the collection ID await PopulateCidAsync().ConfigureAwait(false); options ??= ExistsOptions.Default; using var rootSpan = RootSpan(OuterRequestSpans.ServiceSpan.Kv.GetMetaExists); using var getMetaOp = new GetMeta { Key = id, Cid = Cid, CName = Name, SName = ScopeName, Span = rootSpan }; _operationConfigurator.Configure(getMetaOp, options); using var cts = CreateRetryTimeoutCancellationTokenSource(options, getMetaOp, out var tokenPair); await _bucket.RetryAsync(getMetaOp, tokenPair).ConfigureAwait(false); var result = getMetaOp.GetValue(); return(new ExistsResult { Cas = getMetaOp.Cas, Exists = !result.Deleted }); } catch (DocumentNotFoundException) { return(new ExistsResult { Exists = false }); } }
public async Task <IExistsResult> ExistsAsync(string id, ExistsOptions?options = null) { try { //sanity check for deferred bootstrapping errors _bucket.ThrowIfBootStrapFailed(); options ??= new ExistsOptions(); using var rootSpan = RootSpan(OperationNames.GetMetaExists); using var getMetaOp = new GetMeta { Key = id, Cid = Cid, CName = Name, Span = rootSpan }; _operationConfigurator.Configure(getMetaOp, options); await RetryUntilTimeoutOrSuccessAsync(options.TokenValue, options.TimeoutValue, getMetaOp).ConfigureAwait(false); var result = getMetaOp.GetValue(); return(new ExistsResult { Cas = getMetaOp.Cas, Exists = !result.Deleted }); } catch (DocumentNotFoundException) { return(new ExistsResult { Exists = false }); } }