Example with Polly.CacheAsync with ResultTtl strategy needed
See original GitHub issueI’ve tried to create a CachePolicy using the ResultTtl strategy. It happens that I have to use IAsyncCacheProvider<TResult>
to make it possible, at least against Polly 5.9.0
Unfortunatly I cannot find out how to create such provider. My best guess was to use IDistributedCache provider and a serializer but currently the package doesn’t look present on nuget https://www.nuget.org/packages/polly.caching.serialization.json
Could someone guide me further on this?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Example with Polly.CacheAsync with ResultTtl strategy ...
I've tried to create a CachePolicy using the ResultTtl strategy. It happens that I have to use IAsyncCacheProvider<TResult> to make it ...
Read more >Dynamic caching policy with Polly
Polly is great library for easily configuring different kinds of policies around code execution, be it retry, circuit breaker, caching or ...
Read more >Selectively Caching a HttpResponseMessage with Polly
This article will demonstrate how to selectively cache HttpResponseMessages based on the Http StatusCode of the response. The second will show ...
Read more >Caching in Polly and the HttpClientFactory - no dogma blog
Polly allows you to cache a response for reuse by a subsequent request, it supports both local an distributed caches, full information can...
Read more >Cache - App-vNext/Polly GitHub Wiki
ResultTtl : specifies a function that will be used to calculate the ttl based on the TResult item to be cached. This is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I tried the following code with polly 5.9.0 but I get the following error compiling.
Argument 2: cannot convert from ‘Polly.Caching.ResultTtl<(string AccessToken, System.DateTimeOffset ExpiresOn)>’ to ‘System.TimeSpan’
And makes sense as there is no overload that accept
ITtlStrategy<TResult>
and a plainIAsyncCacheProvider
. It requiresIAsyncCacheProvider<TResult>
but I do not find how to make one. If I update to Polly v6, there is a version clashing wherePolly.Caching.MemoryCache.MemoryCacheProvider
doesn’t implementPolly.Caching.IAsyncCacheProvider
from v6 and requires v5.9Am I doing something wrong?
Documentation now added: https://github.com/App-vNext/Polly.Caching.MemoryCache#note . Thanks for highlighting this issue!