Exemplo n.º 1
0
 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) !);
 }
Exemplo n.º 2
0
    // 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 !);
        }
    }
Exemplo n.º 3
0
 public override ValueTask <Option <TValue> > TryGet(TKey key, CancellationToken cancellationToken = default)
 => ValueTaskExt.FromResult(Option.None <TValue>());
Exemplo n.º 4
0
 public ValueTask <JsonString> ThreeXAsync()
 => ValueTaskExt.FromResult(Three());
Exemplo n.º 5
0
 public ValueTask <int> TwoXAsync(string source)
 => ValueTaskExt.FromResult(Two(source));
Exemplo n.º 6
0
 public ValueTask <string> OneXAsync(string source)
 => ValueTaskExt.FromResult(One(source));