Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

darthfabar/DistributedCachePollyDecorator

Open more actions menu

DistributedCachePollyDecorator

GitHub Actions Status

GitHub Actions Build History

What Does This Package Do?

With this package you can inject Polly policy behaviours to the IDistributedCache interface. Right now it enables you to have a circuitbreaker policy that enables you to fail fast in case you Redis is down or your app runs into connection errors.

How to use the package:

Just add a 'AddDistributedCacheDecorator' call in your Startup.cs / any other place where you do your registrations

	public void ConfigureServices(IServiceCollection services)
	{

		services.AddControllers();

		// your settings for Redis
		services.AddStackExchangeRedisCache(options =>
		{
			options.Configuration = "localhost:6379,allowAdmin=true,DefaultDatabase=1";
		});

		// Decorate the inferface with a simple circuit breaker
		services.AddDistributedCacheDecorator(new CircuitBreakerSettings()
		{
			DurationOfBreak = TimeSpan.FromMinutes(5),
			ExceptionsAllowedBeforeBreaking = 2
		});

		// OR decorate it with an advanced one: (don't add both)
		services.AddDistributedCacheDecorator(new CircuitBreakerAdvancedSettings()
		{
			DurationOfBreak = TimeSpan.FromMinutes(5),
			FailureThreshold = 0.5,
			MinimumThroughput = 100,
			SamplingDuration = TimeSpan.FromMinutes(2)
		});
	}

Install Package

dotnet add package DistributedCachePollyDecorator --version 1.0.0

Or go to https://www.nuget.org/packages/DistributedCachePollyDecorator/

About

Add Polly policies to your IDistributedCache interface to handle cache downtimes

Topics

Resources

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE.md

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.