Sylin.Koan.Cache
0.20.4
dotnet add package Sylin.Koan.Cache --version 0.20.4
NuGet\Install-Package Sylin.Koan.Cache -Version 0.20.4
<PackageReference Include="Sylin.Koan.Cache" Version="0.20.4" />
<PackageVersion Include="Sylin.Koan.Cache" Version="0.20.4" />
<PackageReference Include="Sylin.Koan.Cache" />
paket add Sylin.Koan.Cache --version 0.20.4
#r "nuget: Sylin.Koan.Cache, 0.20.4"
#:package Sylin.Koan.Cache@0.20.4
#addin nuget:?package=Sylin.Koan.Cache&version=0.20.4
#tool nuget:?package=Sylin.Koan.Cache&version=0.20.4
Sylin.Koan.Cache
Business-shaped caching for Koan Entities, with a process-local provider that works immediately and deterministic provider composition when adapters are referenced.
Install
dotnet add package Sylin.Koan.Cache
Keep the normal Koan boot and declare the policy where the business type lives:
builder.Services.AddKoan();
[Cacheable(300)]
public sealed class Todo : Entity<Todo>
{
public string Title { get; set; } = "";
}
That is the complete shortest path. Todo.Get, Save, and Delete retain their normal meaning; Cache applies
read-through and invalidation behind the Entity repository. No cache-specific registration belongs in
Program.cs.
Meaningful result
var todo = await Todo.Get(id, ct); // cache-aware read
todo.Title = "done";
await todo.Save(ct); // business write; cache state follows
var policy = Todo.Cache.Explain(); // inspect the effective Entity policy
var removed = await todo.Cache.Evict(ct); // after an out-of-band write
var flushed = await Todo.Cache.Flush(ct); // type/tag control plane
Scalar, finite, and async-stream Cache.Evict() forms preserve source order and apply sequential backpressure.
Ordinary Entity writes already maintain cache state; explicit eviction is for writes that intentionally bypassed
the repository.
Direct cache entries
Use ICacheClient or the Cache facade when the cached value is not an Entity repository result:
var report = await Cache.WithJson<UsageReport>($"usage:{tenantId}")
.WithAbsoluteTtl(TimeSpan.FromMinutes(10))
.WithTags("usage")
.GetOrAdd(ct => BuildReport(tenantId, ct), ct);
Fresh-or-miss is the default. AllowStaleFor opts a read into a bounded stale-serving window; it does not promise
background revalidation. WithTier(CacheTier.LocalOnly) and WithTier(CacheTier.RemoteOnly) express an explicit
operation requirement and fail clearly when that tier is unavailable. Layered is the default and uses every
available selected tier.
Composition by reference
| Direct reference | Effect |
|---|---|
Sylin.Koan.Cache |
Built-in process-memory Local floor |
Sylin.Koan.Cache.Adapter.Sqlite |
Persistent Local candidate; wins automatic Local election |
Sylin.Koan.Cache.Adapter.Redis |
Remote Redis candidate plus layered peer-broadcast capability |
Koan compiles Local and Remote election once from standard .NET DI candidates. An optional host-wide
Cache:LocalProvider or Cache:RemoteProvider pin overrides priority and fails closed when unavailable. Per-policy
provider pins do not exist; a policy chooses semantic tier, while the host owns infrastructure selection.
Each store declares guarantees through CacheCaps. Operations negotiate the capabilities they require—tags,
sliding expiry, bounded stale serving, or binary payloads—before invoking the provider.
Startup and operations
Boot reporting and composition facts expose:
- every available store, placement, priority, and declared capabilities;
- selected Local/Remote receipts and effective topology;
- default tier, TTL, L1 TTL, and invalidation posture;
- peer-broadcast provider and assurance; and
- materialized Entity policies, resolved entry plans, and safety exclusions.
CacheHealthCheck probes each selected tier and reports coherence posture. Facts can be projected through Koan's
operator and agent surfaces when those host modules are present.
Honest limits
Cache does not claim cross-store transactions, batch atomicity, durable invalidation replay, remote handler settlement, or automatic stale-value revalidation. Peer invalidation is a bounded best-effort hint; L1 TTL remains part of the correctness posture.
See the Cache reference and technical notes.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- Microsoft.Extensions.Caching.Memory (>= 10.0.10)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.10)
- Microsoft.Extensions.DependencyModel (>= 10.0.10)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 10.0.10)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.10)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.10)
- Microsoft.Extensions.Options (>= 10.0.10)
- Newtonsoft.Json (>= 13.0.4)
- Sylin.Koan.Cache.Abstractions (>= 0.20.2 && < 0.21.0)
- Sylin.Koan.Communication (>= 0.20.6 && < 0.21.0)
- Sylin.Koan.Core (>= 0.20.6 && < 0.21.0)
- Sylin.Koan.Data.Abstractions (>= 0.20.5 && < 0.21.0)
- Sylin.Koan.Data.Core (>= 0.20.5 && < 0.21.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Sylin.Koan.Cache:
| Package | Downloads |
|---|---|
|
Sylin.Koan.Cache.Adapter.Sqlite
SQLite-backed persistent L1 cache store for Koan.Cache. Provides on-disk cache persistence with tag indexing and TTL eviction. Preempts the default Memory store by ProviderPriority. |
|
|
Sylin.Koan.Mcp.Operations
Governed MCP operations for Koan Jobs and Cache, with explicit enablement, exact grants, destructive confirmation, and mutation audit. |
|
|
Sylin.Koan.Cache.Adapter.Redis
Redis-backed L2 cache store for Koan.Cache. Provides distributed cache storage and Redis pub/sub coherence channel via Koan.Data.Connector.Redis's shared IConnectionMultiplexer (ARCH-0080). |
GitHub repositories
This package is not used by any popular GitHub repositories.