Skip to content

Latest commit

 

History

History
62 lines (46 loc) · 2.99 KB

README.md

File metadata and controls

62 lines (46 loc) · 2.99 KB

RedisMemoryCacheInvalidation

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 : https://techblog.betclicgroup.com/2013/12/31/implementing-local-memorycache-invalidation-with-redis/

License

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