CacheManager.SystemRuntimeCaching
2.0.0
dotnet add package CacheManager.SystemRuntimeCaching --version 2.0.0
NuGet\Install-Package CacheManager.SystemRuntimeCaching -Version 2.0.0
<PackageReference Include="CacheManager.SystemRuntimeCaching" Version="2.0.0" />
paket add CacheManager.SystemRuntimeCaching --version 2.0.0
#r "nuget: CacheManager.SystemRuntimeCaching, 2.0.0"
// Install CacheManager.SystemRuntimeCaching as a Cake Addin #addin nuget:?package=CacheManager.SystemRuntimeCaching&version=2.0.0 // Install CacheManager.SystemRuntimeCaching as a Cake Tool #tool nuget:?package=CacheManager.SystemRuntimeCaching&version=2.0.0
CacheManager is an open source caching abstraction layer for .NET written in C#. It supports various cache providers and implements many advanced features.
The main goal of the CacheManager package is to make developer's life easier to handle even very complex caching scenarios.
With CacheManager it is possible to implement multiple layers of caching, e.g. in-process caching in front of a distributed cache, in just a few lines of code.
CacheManager is not just an interface to unify the programming model for various cache providers, which will make it very easy to change the caching strategy later on in a project. It also offers additional features, like cache synchronization, concurrent updates, serialization, events, performance counters... The developer can opt-in to those features only if needed.
Build Status
Branch | Status |
---|---|
Dev | |
Master |
CacheManager Nuget Packages
Package Name | FullFramework | .NET Standard | net8.0 |
---|---|---|---|
CacheManager.Core | 4.7.2 | 2.0 | net8.0 |
CacheManager.Microsoft.Extensions.Caching.Memory | - | 2.0 | net8.0 |
CacheManager.Microsoft.Extensions.Configuration | - | 2.0 | net8.0 |
CacheManager.Serialization.Bond | - | 2.0 | net8.0 |
CacheManager.Serialization.DataContract | - | 2.0 | net8.0 |
CacheManager.Serialization.Json | - | 2.0 | net8.0 |
CacheManager.Serialization.ProtoBuf | - | 2.0 | net8.0 |
CacheManager.StackExchange.Redis | 4.7.2 | 2.0 | net8.0 |
CacheManager.SystemRuntimeCaching | 4.7.2 | 2.0 | net8.0 |
Version 2.0 Breaking Changes
- CacheManager.Microsoft.Extensions.Logging is not a separated package anymore. Logging is now part of the Core package.
- CacheManager.Memcached is not supported anymore
- CacheManager.Couchbase is not supported anymore
- CacheManager.Web is not supported anymore
- PerformanceCounters are not available for now
Testing with Microsoft.Garnet
For testing and benchmarking, this project is now using Microsoft.Garnet, which allows to create a Redis server which runs in process and is easy to setup. This has some limitations though and before you use Microsoft.Garnet in production, be aware that for example key space notifications are not supported yet.
See https://github.com/microsoft/garnet for details.
Beta Packages
Beta versions of the CacheManager packages are getting pushed to https://www.myget.org/gallery/cachemanager on each build. Add the following feed, if you want to play with the not yet released bits:
https://www.myget.org/F/cachemanager/api/v3/index.json
To find which check-in created which build, use this build history.
Documentation
Documentation can be found on cachemanager.michaco.net:
- Getting Started
- Configuration
- Features and Architecture
- Update Operations
- Serialization
- Cache Synchronization
- Logging
Generated API documentation is also available.
Blog Posts
CacheManager related blog posts can be found on my website
Examples
- Examples included in the Cache Manager repository
- Single Page Todo App with Cache Manager on Azure using Redis
Benchmarks
See benchmarks results on GitHub.
List of Features
- One common interface for handling different caching technologies:
ICache<T>
- Configurable by
- Code with many different paths and a fluent configuration builder
- Microsoft.Extensions.Configuration
- App/Web.config
- See configuration docs
- Support for different cache providers
- MemoryCache (System.Runtime.Caching)
- MemoryCache based on Microsoft.Extensions.Caching.Memory
- Redis using StackExchange.Redis
- Serialization can now be configured.
Serialization is only needed in distributed caches. If no additional serialization package is installed and configured, Binary serialization will be used (if available)
The following are the currently available serialization options:
- Binary (build in if the full CLR is being used)
- Json based on the popular Newtonsoft.Json library
- Json with Gzip compression
- Bond based on Microsoft.Bond supporting all three available variants
- DataContract based on System.Runtime.Serialization library supporting binary, Json & Json with Gzip compression
- Protocol Buffer Google's protobuf. The package uses Mark's protobuf-net implementation.
- Update values with lock or transaction for distributed caches. The interfaced provides a simple update method which internally ensures you work with the latest version. And CacheManager handles version conflicts for you.
- Logging using Microsoft.Extensions.Logging.
- Strongly typed cache interface.
- Multiple layers
By having multiple cache handles managed by CacheManager, you can easily implement layered caches. For example, an in process cache in front of your distributed cache, to make read access faster.
CacheManager will synchronize those layers for you.
Put
andAdd
operations will always be executed on all cache handles registered on the manager.- On
Get
, there are different configuration options defined byCacheUpdateMode
, if the item was available in one cache handle:- None: No update across the cache handles on Get
- Up: Updates the handles "above"
- All: Updates/Adds the item to all handles
- Expiration: It is possible to configure the expiration per cache handle within the manager or per cache item.
The following are the supported expiration modes:
- Sliding expiration: On cache hit, the cache item expiration timeout will be extended by the configured amount.
- Absolute expiration: The cache item will expire after the configured timeout.
- Since 1.0.0, evictions triggered by the cache vendor can trigger events and updates
- Cache Regions: Even if some cache systems do not support or implement cache regions, the CacheManager implements the mechanism. This can be used to for example group elements and remove all of them at once.
- Statistics: Counters for all kind of cache actions.
- Event System: CacheManager triggers events for common cache actions:
OnGet, OnAdd, OnPut, OnRemove, OnClear, OnClearRegion
- Events also get triggered by the backplane (if enabled) when multiple instances are sharing the same cache.
- New
OnRemoveByHandle
events triggered by actual expiration or memory pressure eviction by the cache vendor - Events also get triggered through the backplane and via Redis keyspace events (if configured)
- Cache clients synchronization
- Implemented with the Redis pub/sub feature
Product | Versions 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 is compatible. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 is compatible. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.7.2
- CacheManager.Core (>= 2.0.0)
-
.NETStandard 2.0
- CacheManager.Core (>= 2.0.0)
- System.Runtime.Caching (>= 6.0.0)
-
net8.0
- CacheManager.Core (>= 2.0.0)
- System.Runtime.Caching (>= 8.0.0)
NuGet packages (12)
Showing the top 5 NuGet packages that depend on CacheManager.SystemRuntimeCaching:
Package | Downloads |
---|---|
BSynchro.Cache
Package Description |
|
BSynchro.RatingEngine.Core
Package Description |
|
Hummingbird.Extensions.Cache
分布式缓存 |
|
zAppDev.DotNet.Framework
Package Description |
|
Log2Net
Log2NET is a tool for collecting log to databases or files for .NET and .NETCore. This component automatically collects the system's running logs (server operation, online statistics, etc.), exception logs. programmers can also add custom logs. This component supports.NET platform and.NETCore platform, supports file, sql server, oracle, mysql, and can be easily extended to other databases. |
GitHub repositories (3)
Showing the top 3 popular GitHub repositories that depend on CacheManager.SystemRuntimeCaching:
Repository | Stars |
---|---|
SparkDevNetwork/Rock
An open source CMS, Relationship Management System (RMS) and Church Management System (ChMS) all rolled into one.
|
|
guoming/Hummingbird
分布式锁,分布式ID,分布式消息队列、配置中心、注册中心、服务注册发现、超时、重试、熔断、负载均衡
|
|
SaviorXTanren/mixer-mixitup
Streaming bot application for handling chat, events, moderation, and other streamer assistance features
|
Version | Downloads | Last updated |
---|---|---|
2.0.0 | 104 | 3/6/2025 |
2.0.0-beta-20250302.24 | 58 | 3/2/2025 |
2.0.0-beta-20250302.12 | 58 | 3/2/2025 |
2.0.0-beta-1629 | 415,262 | 11/15/2018 |
1.2.0 | 1,205,625 | 12/6/2018 |
1.1.2 | 802,724 | 11/18/2017 |
1.1.1 | 139,002 | 7/2/2017 |
1.1.0 | 64,385 | 6/5/2017 |
1.0.1 | 59,793 | 4/20/2017 |
1.0.0 | 26,298 | 3/19/2017 |
1.0.0-beta-1456 | 1,290 | 3/14/2017 |
0.9.3 | 505,714 | 2/3/2017 |
0.9.2 | 78,510 | 12/1/2016 |
0.9.1 | 40,487 | 9/23/2016 |
0.9.0 | 20,968 | 8/21/2016 |
0.8.0 | 62,467 | 2/28/2016 |
0.7.4 | 2,129 | 2/14/2016 |
0.7.3 | 1,677 | 2/5/2016 |
0.7.2 | 1,938 | 1/27/2016 |
0.7.1 | 3,769 | 1/20/2016 |
0.7.0 | 3,007 | 12/26/2015 |
0.6.1 | 13,167 | 10/31/2015 |
0.6.0 | 3,876 | 6/9/2015 |
0.5.0 | 3,302 | 4/15/2015 |
0.4.4.1 | 2,107 | 4/10/2015 |
0.4.4 | 2,119 | 4/10/2015 |
0.4.3 | 2,226 | 4/4/2015 |
0.4.2 | 2,168 | 3/31/2015 |
0.4.1 | 2,129 | 3/27/2015 |
0.4.0 | 2,106 | 3/22/2015 |
0.3.1 | 3,841 | 6/16/2014 |
0.3.0 | 2,526 | 3/5/2014 |
0.2.0 | 2,325 | 2/23/2014 |
0.1.5 | 2,675 | 2/16/2014 |