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