![]() |
VOOZH | about |
dotnet add package CasCap.Common.Caching --version 4.12.1
NuGet\Install-Package CasCap.Common.Caching -Version 4.12.1
<PackageReference Include="CasCap.Common.Caching" Version="4.12.1" />
<PackageVersion Include="CasCap.Common.Caching" Version="4.12.1" />Directory.Packages.props
<PackageReference Include="CasCap.Common.Caching" />Project file
paket add CasCap.Common.Caching --version 4.12.1
#r "nuget: CasCap.Common.Caching, 4.12.1"
#:package CasCap.Common.Caching@4.12.1
#addin nuget:?package=CasCap.Common.Caching&version=4.12.1Install as a Cake Addin
#tool nuget:?package=CasCap.Common.Caching&version=4.12.1Install as a Cake Tool
Multi-tier distributed caching library implementing the cache-aside pattern with support for Memory, Disk, and Redis cache layers.
dotnet add package CasCap.Common.Caching
Provides a complete caching infrastructure with local (in-process) and remote (Redis) cache tiers, synchronised expiration via Redis Pub/Sub, and configurable serialization (JSON or MessagePack). Includes background services for cache expiry management, an async duplicate-lock mechanism to prevent thundering-herd scenarios, and optional Redis-based distributed locking via RedLock.net.
Target frameworks: netstandard2.0, net8.0, net9.0, net10.0
| Service | Description |
|---|---|
DistributedCacheService |
Multi-tier cache orchestrator — reads from local first, falls back to Redis, and populates both tiers on miss. Supports opt-in Redis-based distributed locking (Redlock) to prevent thundering herd across instances |
RedisCacheService |
IRemoteCache implementation wrapping StackExchange.Redis with optional Lua script support |
MemoryCacheService |
ILocalCache implementation backed by IMemoryCache |
DiskCacheService |
ILocalCache implementation persisting cache entries to disk |
CacheExpiryBgService |
Background service coordinating expiry synchronisation between local and remote caches |
LocalCacheExpiryService |
Handles local cache entry expiration |
RemoteCacheExpiryService |
Handles remote cache entry expiration |
| Extension | Description |
|---|---|
ServiceCollectionExtensions.AddCasCapCaching() |
Registers all caching services into the DI container. When CachingConfig.HealthCheckRedis is not None, also registers a Redis connectivity health check tagged with the configured Kubernetes probe type(s) |
CachingExtensions |
Helper methods for cache key formatting and serialization |
AsyncDuplicateLock |
Prevents duplicate concurrent cache population for the same key |
| Type | Description |
|---|---|
CachingConfig |
Main configuration record — RemoteCacheConnectionString, PubSubPrefix, MemoryCacheSizeLimit, UseBuiltInLuaScripts, DiskCacheFolder, ExpirationSyncMode, DistributedLockingEnabled, CacheAsideDisabled, CacheKeyFormat, HealthCheckRedis, Redlock |
RedlockConfig |
Timing parameters for Redis distributed locks with named profile support — root defaults (ExpiryMs 5s, WaitMs 5s, RetryMs 250ms) tuned for cache-miss protection. RedisKeyFormat for lock key prefixing. Built-in LeaderElection profile (30s/60s/5s) for long-lived locks. Custom profiles via Profiles dictionary |
RedlockProfiles |
Well-known profile name constants — CacheMiss, LeaderElection |
RedlockTimingProfile |
Timing values for a single named lock profile — ExpiryMs, WaitMs, RetryMs |
CacheParameters |
Per-layer cache configuration (TTL, size limits) |
| Enum | Values |
|---|---|
CacheType |
None, Memory, Disk, Redis |
SerializationType |
None, Json, MessagePack |
ExpirationSyncType |
None, ExpireViaPubSub, ExtendRemoteExpiry |
Multi-tier caching infrastructure with cache-aside pattern:
flowchart TD
CLIENT["Application Code"]
subgraph CachingServices["Caching Services"]
DIST["DistributedCacheService<br/>(Multi-tier orchestrator)"]
subgraph LocalCaches["Local Cache Implementations"]
MEM["MemoryCacheService<br/>(IMemoryCache)"]
DISK["DiskCacheService<br/>(File system)"]
end
subgraph RemoteCaches["Remote Cache"]
REDIS["RedisCacheService<br/>(StackExchange.Redis)"]
end
subgraph BackgroundServices["Background Services"]
EXPIRY_BG["CacheExpiryBgService"]
LOCAL_EXP["LocalCacheExpiryService"]
REMOTE_EXP["RemoteCacheExpiryService"]
end
end
REDIS_SERVER[("Redis Server<br/>(Pub/Sub)")]
LOCK["AsyncDuplicateLock<br/>(Prevent thundering herd)"]
REDLOCK["IDistributedLockFactory<br/>(RedLock.net — optional)"]
CLIENT --> DIST
DIST --> MEM
DIST --> DISK
DIST --> REDIS
DIST -.uses.-> LOCK
DIST -."opt-in distributed lock".-> REDLOCK
REDIS <--> REDIS_SERVER
REDLOCK -."Redlock algorithm".-> REDIS_SERVER
EXPIRY_BG --> LOCAL_EXP
EXPIRY_BG --> REMOTE_EXP
REDIS_SERVER -."Pub/Sub expiry sync".-> LOCAL_EXP
REDIS_SERVER -."Pub/Sub expiry sync".-> REMOTE_EXP
LOCAL_EXP -.expires.-> MEM
LOCAL_EXP -.expires.-> DISK
REMOTE_EXP -.expires.-> REDIS
All configuration lives under the CasCap:CachingConfig section in appsettings.json. Properties omitted from the JSON use their record defaults.
{
"CasCap": {
"CachingConfig": {
"RemoteCacheConnectionString": "localhost:6379,abortConnect=false"
}
}
}
{
"CasCap": {
"CachingConfig": {
"RemoteCacheConnectionString": "localhost:6379,abortConnect=false",
"RemoteCache": {
"SerializationType": "Json"
}
}
}
}
{
"CasCap": {
"CachingConfig": {
"RemoteCacheConnectionString": "localhost:6379,abortConnect=false",
"DistributedLockingEnabled": true,
"RemoteCache": {
"SerializationType": "Json"
}
}
}
}
{
"CasCap": {
"CachingConfig": {
"RemoteCacheConnectionString": "localhost:6379,abortConnect=false",
"DistributedLockingEnabled": true,
"RemoteCache": {
"SerializationType": "Json"
},
"Redlock": {
"ExpiryMs": 5000,
"WaitMs": 5000,
"RetryMs": 250,
"Profiles": {
"LeaderElection": {
"ExpiryMs": 30000,
"WaitMs": 60000,
"RetryMs": 5000
}
}
}
}
}
}
{
"CasCap": {
"CachingConfig": {
"RemoteCacheConnectionString": "redis-sentinel:26379,serviceName=mymaster,abortConnect=false,connectTimeout=1000",
"DistributedLockingEnabled": true,
"CacheKeyFormat": "Production:{0}",
"MemoryCacheSizeLimit": 500,
"UseBuiltInLuaScripts": true,
"DiskCacheFolder": "/var/cache/cascap",
"ExpirationSyncMode": "ExpireViaPubSub",
"MemoryCache": {
"IsEnabled": true,
"ClearOnStartup": false,
"SerializationType": "None"
},
"DiskCache": {
"IsEnabled": false,
"SerializationType": "Json"
},
"RemoteCache": {
"IsEnabled": true,
"DatabaseId": 1,
"ClearOnStartup": false,
"SerializationType": "MessagePack"
},
"Redlock": {
"RedisKeyFormat": "Production:RedLock:{0}",
"ExpiryMs": 5000,
"WaitMs": 5000,
"RetryMs": 250,
"Profiles": {
"LeaderElection": {
"ExpiryMs": 30000,
"WaitMs": 60000,
"RetryMs": 5000
},
"LongRunningJob": {
"ExpiryMs": 120000,
"WaitMs": 30000,
"RetryMs": 10000
}
}
}
}
}
}
| Project | Purpose |
|---|---|
CasCap.Common.Abstractions |
ILocalCache, IAppConfig contracts |
CasCap.Common.Extensions |
General-purpose helper utilities |
CasCap.Common.Serialization.Json |
JSON serialization for cache values |
CasCap.Common.Serialization.MessagePack |
MessagePack serialization for cache values |
CasCap.Common.Logging |
ApplicationLogging static logger factory |
CasCap.Common.Extensions.Diagnostics.HealthChecks |
Kubernetes probe tag helpers (KubernetesProbeTypes.GetTags()) |
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on CasCap.Common.Caching:
| Package | Downloads |
|---|---|
|
CasCap.Common.AI
AI and LLM integration abstractions for OpenAI, Ollama, and Model Context Protocol. |
|
|
CasCap.Api.Knx
.NET client library for KNX building automation — connects via KNXnet/IP tunnelling or routing, monitors group-address telegrams, and fans events out to configurable sinks. |
|
|
CasCap.Api.DoorBird
.NET client library for DoorBird IP video door station — captures doorbell, motion and RFID events via the local LAN API and dispatches them to configurable sinks. |
|
|
CasCap.Api.Fronius.Sinks
Pluggable event sink implementations (Redis, Azure Tables) for the CasCap.Api.Fronius solar inverter integration library. |
|
|
CasCap.Api.Buderus.Sinks
Pluggable event sink implementations (Redis, Azure Tables) for the CasCap.Api.Buderus heating integration library. |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.12.1 | 198 | 6/14/2026 |
| 4.12.0 | 198 | 6/12/2026 |
| 4.11.9 | 232 | 6/10/2026 |
| 4.11.8 | 220 | 5/27/2026 |
| 4.11.7 | 124 | 5/27/2026 |
| 4.11.6 | 247 | 5/26/2026 |
| 4.11.5 | 126 | 5/22/2026 |
| 4.11.4 | 157 | 5/20/2026 |
| 4.11.3 | 387 | 5/13/2026 |
| 4.11.2 | 142 | 5/11/2026 |
| 4.11.1 | 124 | 5/11/2026 |
| 4.11.0 | 295 | 5/8/2026 |
| 4.10.5 | 129 | 5/4/2026 |
| 4.10.4 | 145 | 5/2/2026 |
| 4.10.3 | 332 | 4/24/2026 |
| 4.10.2 | 130 | 4/24/2026 |
| 4.10.1 | 134 | 4/23/2026 |
| 4.10.0 | 121 | 4/23/2026 |
| 4.9.3 | 158 | 4/20/2026 |
| 4.9.2 | 124 | 4/19/2026 |