Skip to content

Commit b4ec3bf

Browse files
committed
Update Readme
1 parent db82965 commit b4ec3bf

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Polly.Caching.MemoryCache supports .NET4.0, .NET4.5 and .NetStandard 1.3.
2828

2929
## Dependencies
3030

31-
Polly.Caching.MemoryCache works with Polly v5.4.0 and above.
31+
Polly.Caching.MemoryCache works with Polly v5.9.0 and above.
3232

3333
# How to use the Polly.Caching.MemoryCache plugin
3434

@@ -64,14 +64,13 @@ public class Startup
6464
{
6565
services.AddMemoryCache();
6666
services.AddSingleton<Polly.Registry.IPolicyRegistry<string>, Polly.Registry.PolicyRegistry>();
67+
services.AddSingleton<Polly.Caching.ISyncCacheProvider, Polly.Caching.MemoryCache.MemoryCacheProvider>(); // Or: IAsyncCacheProvider
6768
// ...
6869
}
6970

70-
public void Configure(..., IPolicyRegistry<string> policyRegistry, IMemoryCache memoryCache)
71+
public void Configure(..., IPolicyRegistry<string> policyRegistry, ISyncCacheProvider cacheProvider)
7172
{
72-
Polly.Caching.MemoryCache.MemoryCacheProvider memoryCacheProvider
73-
= new Polly.Caching.MemoryCache.MemoryCacheProvider(memoryCache);
74-
var cachePolicy = Policy.Cache(memoryCacheProvider, TimeSpan.FromMinutes(5));
73+
var cachePolicy = Policy.Cache(cacheProvider, TimeSpan.FromMinutes(5)); // Or: Policy.CacheAsync(IAsyncCacheProvider, ...)
7574
policyRegistry.Add("myCachePolicy", cachePolicy);
7675
// ...
7776
}
@@ -81,7 +80,7 @@ public class Startup
8180
// (magic string "myCachePolicy" only hard-coded here to keep the example simple!)
8281
public MyController(IPolicyRegistry<string> policyRegistry)
8382
{
84-
_cachePolicy = policyRegistry["myCachePolicy"];
83+
var _cachePolicy = policyRegistry.Get<ISyncPolicy>("myCachePolicy");
8584
// ...
8685
}
8786

0 commit comments

Comments
 (0)