Polly.Caching.MemoryCache-Signed 1.0.0

Prefix Reserved
There is a newer version of this package available.
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                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Polly.Caching.MemoryCache-Signed" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Polly.Caching.MemoryCache-Signed --version 1.0.0                
#r "nuget: Polly.Caching.MemoryCache-Signed, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.0 53,424 4/28/2018
1.0.0 1,364 11/2/2017

## 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