0

我正在寻找一个很好的例子,它描述了使用内存缓存选项在 .net core 2.1 中实现 Polly 缓存。我在启动时配置了缓存设置。

   services.AddSingleton<Polly.Registry.IPolicyRegistry<string>, Polly.Registry.PolicyRegistry>((serviceProvider) =>
                {
                    PolicyRegistry registry = new PolicyRegistry();
                    registry.Add("myCachePolicy", Policy.CacheAsync<HttpResponseMessage>(serviceProvider.GetRequiredService<IAsyncCacheProvider>().AsyncFor<HttpResponseMessage>(), TimeSpan.FromMinutes(5)));
                    return registry;
                });
4

0 回答 0