CoreSystem.Cache.Rehydration
2.0.0
dotnet add package CoreSystem.Cache.Rehydration --version 2.0.0
NuGet\Install-Package CoreSystem.Cache.Rehydration -Version 2.0.0
<PackageReference Include="CoreSystem.Cache.Rehydration" Version="2.0.0" />
<PackageVersion Include="CoreSystem.Cache.Rehydration" Version="2.0.0" />
<PackageReference Include="CoreSystem.Cache.Rehydration" />
paket add CoreSystem.Cache.Rehydration --version 2.0.0
#r "nuget: CoreSystem.Cache.Rehydration, 2.0.0"
#:package CoreSystem.Cache.Rehydration@2.0.0
#addin nuget:?package=CoreSystem.Cache.Rehydration&version=2.0.0
#tool nuget:?package=CoreSystem.Cache.Rehydration&version=2.0.0
π CoreSystem.Cache.Rehydration
Cache recovery component for CoreSystem.Cache on .NET 8
CoreSystem.Cache.Rehydration is an optional recovery component for
CoreSystem.Cache. It restores entries that were kept in the memory fallback
after the primary cache provider becomes healthy again.
The package does not implement a cache provider. It reads tracked entries from the memory fallback and writes them to the current primary storage.
π¦ CoreSystem Ecosystem
| Package | Responsibility |
|---|---|
| CoreSystem.Cache | Cache orchestration, storage resolution and fallback support |
| CoreSystem.Cache.Rehydration | Recovery of tracked fallback entries into the primary storage |
CoreSystem.Cache.Rehydration depends on the abstractions and services provided
by CoreSystem.Cache.
An external primary cache storage implementing IExternalCacheStorage must be
registered before rehydration is enabled.
π Getting Started
Register CoreSystem.Cache and an external primary cache provider first.
services.AddCoreCache(options =>
{
options.InstanceName = "my-app:";
});
services.AddCoreCacheRedis(options =>
{
options.Configuration = redis =>
{
redis.EndPoints.Add("localhost", 6379);
};
});
Then register rehydration:
services.AddCoreCacheRehydration(options =>
{
options.Enabled = true;
options.Interval = TimeSpan.FromSeconds(30);
});
Rehydration registration requires:
- an enabled
Core.Cacheregistration; - an
IExternalCacheStorageregistration.
If the core cache is disabled, the rehydration services are not registered.
If the primary storage is not registered, registration throws an
InvalidOperationException.
π How Recovery Works
The recovery process is driven by entries marked by the core cache with:
CacheEntryOptions.Rehydrate
The memory fallback tracks those entries. During a rehydration cycle:
Memory fallback
β
βΌ
Tracked cache keys
β
βΌ
MemoryRehydrationSource
β
βΌ
CacheRehydrator
β
βΌ
PrimaryRehydrationTarget
β
βΌ
ICacheStorageResolver.Primary
An entry contains its key and value and can also contain its remaining expiration and tags.
The primary storage receives the remaining expiration and tags when they are available.
β€οΈ Primary Recovery Detection
Rehydration is not executed simply because the primary is currently healthy.
RehydrationService checks health checks tagged:
primary
A recovery is detected only after the service has observed the primary as unhealthy and subsequently observes it as healthy.
If no health check tagged primary exists, rehydration is not triggered.
After a successful recovery cycle, the component does not repeatedly rehydrate while the primary remains healthy. A new rehydration requires another unhealthy-to-healthy transition.
βοΈ Configuration
RehydrationOptions exposes the following settings:
| Option | Default | Description |
|---|---|---|
Enabled |
true |
Enables registration of the rehydration services |
Interval |
30 seconds |
Delay used by the background rehydration service |
Example:
services.AddCoreCacheRehydration(options =>
{
options.Enabled = true;
options.Interval = TimeSpan.FromSeconds(30);
});
When Enabled is false, the options instance remains registered but the
rehydration source, target, rehydrator, service and hosted background service
are not registered.
π§ Rehydration Behavior
The rehydration component processes tracked entries independently.
When an entry is successfully stored in the primary provider, it is removed from the memory fallback.
If storing an entry fails:
- the failure is logged;
- the entry is not removed from the fallback;
- processing continues with the next entry;
- the entry remains available for a later rehydration cycle.
Expired or unavailable memory entries are ignored by the rehydration source.
π§© Extensibility
The implementation separates the recovery source from the recovery target:
IRehydrationSourceobtains recoverable entries.IRehydrationTargetstores entries in the primary cache.ICacheRehydratorcoordinates the transfer.
The current source and target abstractions are internal implementation boundaries. The package does not currently expose a public provider SDK for replacing the rehydration source or target.
π§ͺ Tests
The available unit tests cover:
- rehydration entry creation and optional properties;
- registration requirements;
- disabled-cache and disabled-rehydration behavior;
- primary storage requirements;
- memory entry tracking and extraction;
- expiration and tag preservation;
- expired-entry handling;
- storage into the primary provider;
- removal after successful storage;
- retention after storage failures;
- continuation after an individual entry failure;
- primary unhealthy-to-healthy recovery detection;
- background cycle execution and cancellation.
π Documentation
- Getting Started
- Basic Usage
- Architecture
- Configuration
- Health Checks
- Observability
- Extensibility
- Roadmap
πΊοΈ Roadmap
The current implementation focuses on reliable recovery of tracked memory fallback entries.
Potential future improvements include additional diagnostics, configurable batch processing and additional recovery policies.
π License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- CoreSystem.Cache (>= 2.0.0)
- CoreSystem.Http (>= 1.0.6)
- CoreSystem.Memory (>= 1.0.0)
- CoreSystem.Observability.Abstractions (>= 1.0.0)
- CoreSystem.Resilience (>= 2.0.0)
- CoreSystem.Serialization (>= 1.2.0)
- MessagePack (>= 3.1.8)
- Microsoft.Extensions.Configuration (>= 8.0.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 8.0.2)
- Microsoft.Extensions.DependencyInjection (>= 8.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 8.0.28)
- Microsoft.Extensions.Options (>= 8.0.2)
- OpenTelemetry (>= 1.15.3)
- OpenTelemetry.Api (>= 1.15.3)
- OpenTelemetry.Extensions.Hosting (>= 1.15.3)
- Polly (>= 8.7.0)
- protobuf-net (>= 3.2.56)
- protobuf-net.Core (>= 3.2.56)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on CoreSystem.Cache.Rehydration:
| Package | Downloads |
|---|---|
|
CoreSystem.Cache.Redis
Redis external cache provider for CoreSystem.Cache on .NET 8, with tag-based invalidation, distributed locking, health checks, and optional resilience integration. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.0 | 95 | 8/16/2026 |