예제 #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));