Example #1
0
        public async Task <IGetResult> GetAndTouchAsync(string id, TimeSpan expiry, GetAndTouchOptions?options = null)
        {
            //sanity check for deferred bootstrapping errors
            _bucket.ThrowIfBootStrapFailed();

            //Get the collection ID
            await PopulateCidAsync().ConfigureAwait(false);

            options ??= GetAndTouchOptions.Default;
            using var rootSpan      = RootSpan(OuterRequestSpans.ServiceSpan.Kv.GetAndTouch);
            using var getAndTouchOp = new GetT <byte[]>(_bucket.Name, id)
                  {
                      Cid     = Cid,
                      CName   = Name,
                      SName   = ScopeName,
                      Expires = expiry.ToTtl(),
                      Span    = rootSpan
                  };
            _operationConfigurator.Configure(getAndTouchOp, options);

            using var cts = CreateRetryTimeoutCancellationTokenSource(options, getAndTouchOp, out var tokenPair);
            await _bucket.RetryAsync(getAndTouchOp, tokenPair).ConfigureAwait(false);

            return(new GetResult(getAndTouchOp.ExtractBody(), getAndTouchOp.Transcoder, _getLogger)
            {
                Id = getAndTouchOp.Key,
                Cas = getAndTouchOp.Cas,
                Flags = getAndTouchOp.Flags,
                Header = getAndTouchOp.Header,
                OpCode = getAndTouchOp.OpCode
            });
        }
Example #2
0
        public async Task <IGetResult> GetAndTouchAsync(string id, TimeSpan expiry, GetAndTouchOptions?options = null)
        {
            //sanity check for deferred bootstrapping errors
            _bucket.ThrowIfBootStrapFailed();

            options ??= new GetAndTouchOptions();
            using var rootSpan      = RootSpan(OperationNames.GetAndTouch);
            using var getAndTouchOp = new GetT <byte[]>(_bucket.Name, id)
                  {
                      Cid     = Cid,
                      CName   = Name,
                      Expires = expiry.ToTtl(),
                      Span    = rootSpan
                  };
            _operationConfigurator.Configure(getAndTouchOp, options);

            await RetryUntilTimeoutOrSuccessAsync(options.TokenValue, options.TimeoutValue, getAndTouchOp).ConfigureAwait(false);

            return(new GetResult(getAndTouchOp.ExtractBody(), getAndTouchOp.Transcoder, _getLogger)
            {
                Id = getAndTouchOp.Key,
                Cas = getAndTouchOp.Cas,
                Flags = getAndTouchOp.Flags,
                Header = getAndTouchOp.Header,
                OpCode = getAndTouchOp.OpCode
            });
        }