public async Task <IExistsResult> ExistsAsync(string id, ExistsOptions?options = null)
        {
            try
            {
                //sanity check for deferred bootstrapping errors
                _bucket.ThrowIfBootStrapFailed();

                options ??= new ExistsOptions();

                using var getMetaOp = new GetMeta
                      {
                          Key        = id,
                          Cid        = Cid,
                          CName      = Name,
                          Transcoder = _transcoder
                      };

                await _bucket.SendAsync(getMetaOp, options.TokenValue, options.TimeoutValue).ConfigureAwait(false);

                var result = getMetaOp.GetValue();
                return(new ExistsResult
                {
                    Cas = getMetaOp.Cas,
                    Exists = !result.Deleted
                });
            }
            catch (DocumentNotFoundException)
            {
                return(new ExistsResult
                {
                    Exists = false
                });
            }
        }
Beispiel #2
0
        public async Task <IExistsResult> ExistsAsync(string id, ExistsOptions?options = null)
        {
            //sanity check for deferred bootstrapping errors
            _bucket.ThrowIfBootStrapFailed();

            options ??= new ExistsOptions();
            using var existsOp = new Observe
                  {
                      Key        = id,
                      Cid        = Cid,
                      CName      = Name,
                      Transcoder = _transcoder
                  };
            try
            {
                await _bucket.SendAsync(existsOp, options.TokenValue, options.TimeoutValue);

                var value = existsOp.GetValue();
                return(new ExistsResult
                {
                    Exists = existsOp.Success && value.KeyState != KeyState.NotFound &&
                             value.KeyState != KeyState.LogicalDeleted,
                    Cas = value.Cas,
                    Expiry = TimeSpan.FromMilliseconds(existsOp.Expires)
                });
            }
            catch (KeyNotFoundException)
            {
                return(new ExistsResult
                {
                    Exists = false
                });
            }
        }
Beispiel #3
0
        public async Task <IExistsResult> ExistsAsync(string id, ExistsOptions?options = null)
        {
            try
            {
                //sanity check for deferred bootstrapping errors
                _bucket.ThrowIfBootStrapFailed();

                //Check to see if the CID is needed
                if (RequiresCid())
                {
                    //Get the collection ID
                    await PopulateCidAsync().ConfigureAwait(false);
                }

                options ??= ExistsOptions.Default;

                using var rootSpan  = RootSpan(OuterRequestSpans.ServiceSpan.Kv.GetMetaExists, options.RequestSpanValue);
                using var getMetaOp = new GetMeta
                      {
                          Key   = id,
                          Cid   = Cid,
                          CName = Name,
                          SName = ScopeName,
                          Span  = rootSpan
                      };
                _operationConfigurator.Configure(getMetaOp, options);

                using var ctp = CreateRetryTimeoutCancellationTokenSource(options, getMetaOp);
                await _bucket.RetryAsync(getMetaOp, ctp.TokenPair).ConfigureAwait(false);

                var result = getMetaOp.GetValue();

                return(new ExistsResult
                {
                    Cas = getMetaOp.Cas,
                    Exists = !result.Deleted
                });
            }
            catch (DocumentNotFoundException)
            {
                return(new ExistsResult
                {
                    Exists = false
                });
            }
        }
Beispiel #4
0
        public async Task <IExistsResult> ExistsAsync(string id, ExistsOptions?options = null)
        {
            try
            {
                //sanity check for deferred bootstrapping errors
                _bucket.ThrowIfBootStrapFailed();

                options ??= ExistsOptions.Default;

                using var rootSpan  = RootSpan(OperationNames.GetMetaExists);
                using var getMetaOp = new GetMeta
                      {
                          Key   = id,
                          Cid   = Cid,
                          CName = Name,
                          Span  = rootSpan
                      };
                _operationConfigurator.Configure(getMetaOp, options);

                using var cts = CreateRetryTimeoutCancellationTokenSource(options, getMetaOp);
                await _bucket.RetryAsync(getMetaOp, cts.Token).ConfigureAwait(false);

                var result = getMetaOp.GetValue();

                return(new ExistsResult
                {
                    Cas = getMetaOp.Cas,
                    Exists = !result.Deleted
                });
            }
            catch (DocumentNotFoundException)
            {
                return(new ExistsResult
                {
                    Exists = false
                });
            }
        }
Beispiel #5
0
 public Task <IExistsResult> ExistsAsync(string id, ExistsOptions?options = null)
 {
     throw new NotImplementedException();
 }