Polly.Caching.MemoryCache-Signed
1.0.0
Prefix Reserved
See the version list below for details.
dotnet add package Polly.Caching.MemoryCache-Signed --version 1.0.0
NuGet\Install-Package Polly.Caching.MemoryCache-Signed -Version 1.0.0
<PackageReference Include="Polly.Caching.MemoryCache-Signed" Version="1.0.0" />
paket add Polly.Caching.MemoryCache-Signed --version 1.0.0
#r "nuget: Polly.Caching.MemoryCache-Signed, 1.0.0"
// Install Polly.Caching.MemoryCache-Signed as a Cake Addin #addin nuget:?package=Polly.Caching.MemoryCache-Signed&version=1.0.0 // Install Polly.Caching.MemoryCache-Signed as a Cake Tool #tool nuget:?package=Polly.Caching.MemoryCache-Signed&version=1.0.0
Polly.Caching.MemoryCache
This repo contains the MemoryCache plugin for the Polly Cache policy. It targets .NET 4.0, .NET 4.5 and .NET Standard 1.3.
What is Polly?
Polly is a .NET resilience and transient-fault-handling library that allows developers to express policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, Cache aside and Fallback in a fluent and thread-safe manner. Polly targets .NET 4.0, .NET 4.5 and .NET Standard 1.1.
Polly is a member of the .NET Foundation!
Keep up to date with new feature announcements, tips & tricks, and other news through www.thepollyproject.org
Installing Polly.Caching.MemoryCache via NuGet
Install-Package Polly.Caching.MemoryCache
You can install the Strongly Named version via:
Install-Package Polly.Caching.MemoryCache-Signed
Supported targets
Polly.Caching.MemoryCache supports .NET4.0, .NET4.5 and .NetStandard 1.3.
Dependencies
Polly.Caching.MemoryCache works with Polly v5.4.0 and above.
How to use the Polly.Caching.MemoryCache plugin
// (1a): Create a MemoryCacheProvider instance in the .NET Framework, using the Polly.Caching.MemoryCache nuget package.
// (full namespaces and types only shown here for disambiguation)
Polly.Caching.MemoryCache.MemoryCacheProvider memoryCacheProvider
= new Polly.Caching.MemoryCache.MemoryCacheProvider(System.Runtime.Caching.MemoryCache.Default);
// Or (1b): Create a MemoryCacheProvider instance in .NET Core / .NET Standard.
// (full namespaces and types only shown here for disambiguation)
// NB Only if you want to create your own Microsoft.Extensions.Caching.Memory.MemoryCache instance:
Microsoft.Extensions.Caching.Memory.IMemoryCache memoryCache
= new Microsoft.Extensions.Caching.Memory.MemoryCache(new Microsoft.Extensions.Caching.Memory.MemoryCacheOptions());
Polly.Caching.MemoryCache.MemoryCacheProvider memoryCacheProvider
= new Polly.Caching.MemoryCache.MemoryCacheProvider(memoryCache);
// (2) Create a Polly cache policy using that Polly.Caching.MemoryCache.MemoryCacheProvider instance.
var cachePolicy = Policy.Cache(memoryCacheProvider, TimeSpan.FromMinutes(5));
// Or (1c): Configure by dependency injection within ASP.NET Core
// See https://docs.microsoft.com/en-us/aspnet/core/performance/caching/memory
// and https://docs.microsoft.com/en-us/aspnet/core/fundamentals/dependency-injection#registering-your-own-services
// (In this example we choose to pass a whole PolicyRegistry by dependency injection rather than the individual policy, on the assumption the webapp will probably use multiple policies across the app.)
// For example:
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddMemoryCache();
services.AddSingleton<Polly.Registry.IPolicyRegistry<string>, Polly.Registry.PolicyRegistry>();
// ...
}
public void Configure(..., IPolicyRegistry<string> policyRegistry, IMemoryCache memoryCache)
{
Polly.Caching.MemoryCache.MemoryCacheProvider memoryCacheProvider
= new Polly.Caching.MemoryCache.MemoryCacheProvider(memoryCache);
var cachePolicy = Policy.Cache(memoryCacheProvider, TimeSpan.FromMinutes(5));
policyRegistry.Add("myCachePolicy", cachePolicy);
// ...
}
}
// In a controller, inject the policyRegistry and retrieve the policy:
// (magic string "myCachePolicy" only hard-coded here to keep the example simple!)
public MyController(IPolicyRegistry<string> policyRegistry)
{
_cachePolicy = policyRegistry["myCachePolicy"];
// ...
}
For many more configuration options and usage examples of the main Polly CachePolicy
, see the main Polly readme and deep doco on the Polly wiki.
Release notes
For details of changes by release see the change log.
Acknowledgements
- @reisenberger - MemoryCache implementation
- @seanfarrow and @reisenberger - Initial caching architecture in the main Polly repo
- @kesmy - original structuring of the build for msbuild15, in the main Polly repo
Instructions for Contributing
Please check out our Wiki for contributing guidelines. We are following the excellent GitHub Flow process, and would like to make sure you have all of the information needed to be a world-class contributor!
Since Polly is part of the .NET Foundation, we ask our contributors to abide by their Code of Conduct.
Also, we've stood up a Slack channel for easier real-time discussion of ideas and the general direction of Polly as a whole. Be sure to join the conversation today!
License
Licensed under the terms of the New BSD License
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp1.0 was computed. netcoreapp1.1 was computed. netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard1.3 is compatible. netstandard1.4 was computed. netstandard1.5 was computed. netstandard1.6 was computed. netstandard2.0 was computed. netstandard2.1 was computed. |
.NET Framework | net40 is compatible. net403 was computed. net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen30 was computed. tizen40 was computed. tizen60 was computed. |
Universal Windows Platform | uap was computed. uap10.0 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.0
- Microsoft.Bcl (>= 1.1.10)
- Microsoft.Bcl.Async (>= 1.0.168)
- Microsoft.Bcl.Build (>= 1.0.21)
- Nito.AsyncEx (>= 3.0.1)
- Polly.Net40Async (>= 5.4.0)
-
.NETFramework 4.5
- Polly (>= 5.4.0)
-
.NETStandard 1.3
- Microsoft.Extensions.Caching.Memory (>= 1.1.2)
- NETStandard.Library (>= 1.6.1)
- Polly (>= 5.4.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
## 1.0-RC
- Upgrade to Polly v5.4.0
- Correctly state RC dependency (Polly v5.4.0)
## 0.2-alpha
- Upgrade to msbuild15 build process
- Upgrade to Polly v5.3.1
## 0.1-alpha
- Stub repo for Polly.Caching.MemoryCache with first build script