AsyncGenericCacheProvider<TCacheFormat>
Provides a strongly-typed wrapper over a non-generic CacheProviderAsync.
using System;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
namespace Polly.Caching
{
[System.Runtime.CompilerServices.NullableContext(1)]
[System.Runtime.CompilerServices.Nullable(0)]
internal sealed class AsyncGenericCacheProvider<[System.Runtime.CompilerServices.Nullable(2)] TCacheFormat> : IAsyncCacheProvider<TCacheFormat>
{
private readonly IAsyncCacheProvider _wrappedCacheProvider;
internal AsyncGenericCacheProvider(IAsyncCacheProvider nonGenericCacheProvider)
{
if (nonGenericCacheProvider == null)
throw new ArgumentNullException("nonGenericCacheProvider");
_wrappedCacheProvider = nonGenericCacheProvider;
}
[AsyncStateMachine(typeof(AsyncGenericCacheProvider<>.<Polly-Caching-IAsyncCacheProvider<TCacheFormat>-TryGetAsync>d__2))]
[return: System.Runtime.CompilerServices.Nullable(new byte[] {
1,
0,
2
})]
Task<(bool, TCacheFormat)> IAsyncCacheProvider<TCacheFormat>.TryGetAsync(string key, CancellationToken cancellationToken, bool continueOnCapturedContext)
{
<Polly-Caching-IAsyncCacheProvider<TCacheFormat>-TryGetAsync>d__2 stateMachine = default(<Polly-Caching-IAsyncCacheProvider<TCacheFormat>-TryGetAsync>d__2);
stateMachine.<>t__builder = AsyncTaskMethodBuilder<(bool, TCacheFormat)>.Create();
stateMachine.<>4__this = this;
stateMachine.key = key;
stateMachine.cancellationToken = cancellationToken;
stateMachine.continueOnCapturedContext = continueOnCapturedContext;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
Task IAsyncCacheProvider<TCacheFormat>.PutAsync(string key, [System.Runtime.CompilerServices.Nullable(2)] TCacheFormat value, Ttl ttl, CancellationToken cancellationToken, bool continueOnCapturedContext)
{
return _wrappedCacheProvider.PutAsync(key, value, ttl, cancellationToken, continueOnCapturedContext);
}
}
}