protected override ValueTask <string?> Load(string key, CancellationToken cancellationToken) { if (!Storage.TryGetValue(key, out var value)) { return(ValueTaskExt.FromResult((string?)null)); } ExpirationTimers.AddOrUpdateToLater(key, Clock.Now + ExpirationTime); return(ValueTaskExt.FromResult(value) !); }
// Protected methods protected static void SetReturnValue(ComputeMethodInput input, Result <TOut> output) { if (input.Method.ReturnsValueTask) { input.Invocation.ReturnValue = // ReSharper disable once HeapView.BoxingAllocation output.IsValue(out var v) ? ValueTaskExt.FromResult(v) : ValueTaskExt.FromException <TOut>(output.Error !); } else { input.Invocation.ReturnValue = output.IsValue(out var v) ? Task.FromResult(v) : Task.FromException <TOut>(output.Error !); } }
public override ValueTask <Option <TValue> > TryGet(TKey key, CancellationToken cancellationToken = default) => ValueTaskExt.FromResult(Option.None <TValue>());
public ValueTask <JsonString> ThreeXAsync() => ValueTaskExt.FromResult(Three());
public ValueTask <int> TwoXAsync(string source) => ValueTaskExt.FromResult(Two(source));
public ValueTask <string> OneXAsync(string source) => ValueTaskExt.FromResult(One(source));