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 Task <IExistsResult> Exists(string id, Action <ExistsOptions> optionsAction) { var options = new ExistsOptions(); optionsAction(options); return(Exists(id, options)); }
public Task <IExistsResult> Exists(string id, Action <ExistsOptions> configureOptions) { var options = new ExistsOptions(); configureOptions?.Invoke(options); return(Exists(id, options)); }
public static Task <IExistsResult> ExistsAsync(this ICollection collection, string id, Action <ExistsOptions> configureOptions) { var options = new ExistsOptions(); configureOptions?.Invoke(options); return(collection.ExistsAsync(id, options)); }
public Task <IExistsResult> Exists(string id, TimeSpan?timeout = null, CancellationToken token = default(CancellationToken)) { var options = new ExistsOptions { Timeout = timeout, Token = token }; return(Exists(id, options)); }