Skip to content
Local Memory Cache invalidation powered by Redis PubSub
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.


Build status Nuget Nuget Coverage Status

System.Runtime.MemoryCache invalidation using Redis PubSub feature.

Installing via NuGet

Install-Package RedisMemoryCacheInvalidation

How to use it ?

quick start

First, you have to configure the library, mainly to setup a persistent redis connection and various stuff

  // somewhere in your global.asax/startup.cs
  InvalidationManager.Configure("localhost:6379", new InvalidationSettings());

Redis connection string follow StackExchange.Redis Configuration model

Threre are at least 3 ways to send invalidation messages :

  • send an invalidation message via any redis client following the command PUBLISH invalidate onemessagekey
  • use InvalidationManager.InvalidateAsync (same as the previous one)
  • use keyspace notification (yes, RedisMemoryCacheInvalidation supports it)

Once an invalidation message is intercepted by the library, you can invalidate one or more items at the same time by using InvalidationSettings.InvalidationStrategy

  • InvalidationStrategyType.ChangeMonitor => a custom custom change monitor InvalidationManager.CreateChangeMonitor
  • InvalidationStrategyType.AutoCacheRemoval => use the automatic MemoryCache removal configured at InvalidationSettings.ConfigureAsync
  • InvalidationStrategyType.External => use the callback configured at InvalidationSettings.InvalidationCallback

Read more

How it works ?

Read the introduction post for the initial version (beginning of 2014) here :


Licensed under the terms of the MIT License

Want to contribute ?

  • Beginner => Download, Star, Comment/Tweet, Kudo, ...
  • Amateur => Ask for help, send feature request, send bugs
  • Pro => Pull request, promote

Thank you

You can’t perform that action at this time.