public async Task <IExistsResult> ExistsAsync(string id, ExistsOptions options) { 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 static Task <IExistsResult> ExistsAsync(this ICouchbaseCollection collection, string id, Action <ExistsOptions> configureOptions) { var options = new ExistsOptions(); configureOptions?.Invoke(options); return(collection.ExistsAsync(id, options)); }