public async Task <IExistsResult> ExistsAsync(string id, ExistsOptions options = null) { options = options ?? new ExistsOptions(); using (var existsOp = new Observe { Key = id, Cid = Cid, Transcoder = _transcoder }) { try { await _bucket.SendAsync(existsOp, options.Token, options.Timeout); 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 }); } } }
public async Task <IExistsResult> ExistsAsync(string id, ExistsOptions options) { using (var existsOp = new Observe { Key = id, Cid = Cid }) { try { await ExecuteOp(existsOp, options.Token, options.Timeout); var value = existsOp.GetValue(); return(new ExistsResult { Exists = existsOp.Success && value.KeyState != KeyState.NotFound && value.KeyState != KeyState.LogicalDeleted, Cas = value.Cas, Expiration = TimeSpan.FromMilliseconds(existsOp.Expires) }); } catch (KeyNotFoundException) { return(new ExistsResult { Exists = false }); } } }
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 }); } }