Skip to content

antoinebidault/MemoryCacheRedisBackplane.Net

Repository files navigation

Build status Nuget

Logo

MemoryCacheRedisBackplane.Net

An Asp.Net Core Memory cache invalidation (.Net Standard 2.0)

Purpose

The purpose of this library is to keep using the native IMemoryCache that is very fast and reliable for each instance of your application (server farm). The Redis backplane is just used for communication between applications using the Pub/Sub of events.

Purpose

Simple use

In your startup.cs

services.AddMemoryCache();
services.AddMemoryCacheRedisBackplane(Configuration.GetConnectionString("Redis"));

Then in your controllers, if you need to invalidate the cache :

  public TestController(IMemoryCacheInvalidator cacheInvalidator)
  {
      _cacheInvalidator = cacheInvalidator;
  }

  [HttpPost("invalidate")]
  public IActionResult Invalidate()
  {
      // This will invalidate the cache through all the app instances
      _cacheInvalidator.InvalidateAsync(_cacheKey);
      return Ok();
  }

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages