Sylin.Koan.Cache
1.0.65
dotnet add package Sylin.Koan.Cache --version 1.0.65
NuGet\Install-Package Sylin.Koan.Cache -Version 1.0.65
<PackageReference Include="Sylin.Koan.Cache" Version="1.0.65" />
<PackageVersion Include="Sylin.Koan.Cache" Version="1.0.65" />
<PackageReference Include="Sylin.Koan.Cache" />
paket add Sylin.Koan.Cache --version 1.0.65
#r "nuget: Sylin.Koan.Cache, 1.0.65"
#:package Sylin.Koan.Cache@1.0.65
#addin nuget:?package=Sylin.Koan.Cache&version=1.0.65
#tool nuget:?package=Sylin.Koan.Cache&version=1.0.65
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:
using Koan.Core; // AddKoan()
using Koan.Cache.Abstractions.Policies; // Cacheable
using Koan.Data.Core.Model; // Entity<T>, Get
using Koan.Data.Core; // Save
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.
Cache is not the source of truth — the cached Entity still needs a durable store. Reference one Data
connector and configure it (without one, Entity verbs fail with Koan Data has no provider candidates. Reference a Data connector and call AddKoan().):
dotnet add package Sylin.Koan.Data.Connector.Sqlite
"Koan": {
"Data": {
"Sources": {
"Default": {
"Adapter": "sqlite",
"ConnectionString": "Data Source=app.db"
}
}
}
}
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.
Removal and GetOrAdd share one process-local gate per physical key: a completed Remove orders after any
in-flight local fill, so an already-running factory cannot republish a removed value. A layered fill holds the
gate until every tier write it started has settled, so a removal cannot slip between one tier write's failure
and another's still-pending publication. A removal that cannot acquire the gate fails with TimeoutException
or OperationCanceledException and evicts nothing. The ordering is process-local; direct setters and peer
processes are not ordered.
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.
Atomic insertion is forwarded through the existing Entity repository decorator when the selected
provider supports DataCaps.Write.InsertOnly. Proven committed insertion invalidates its cache key;
conflict does not cache or expose the rejected payload or an existing row.
Counterpart predicates use the underlying provider's structured query path and capability. A cached entity is never evidence that its counterpart satisfies a current read constraint; unsupported providers reject the query even when an identity is already cached.
| 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.Configuration (>= 10.0.10)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.10)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.10)
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 10.0.10)
- Microsoft.Extensions.Configuration.Json (>= 10.0.10)
- Microsoft.Extensions.DependencyInjection (>= 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 (>= 10.0.10)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.10)
- Microsoft.Extensions.Logging (>= 10.0.10)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.10)
- Microsoft.Extensions.Logging.Console (>= 10.0.10)
- Microsoft.Extensions.Options (>= 10.0.10)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.10)
- Microsoft.Extensions.Options.DataAnnotations (>= 10.0.10)
- Newtonsoft.Json (>= 13.0.4)
- Sylin.Koan.Cache.Abstractions (>= 1.0.21 && < 2.0.0)
- Sylin.Koan.Communication (>= 1.0.46 && < 2.0.0)
- Sylin.Koan.Core (>= 1.0.39 && < 2.0.0)
- Sylin.Koan.Data.Abstractions (>= 1.0.41 && < 2.0.0)
- Sylin.Koan.Data.Core (>= 1.0.73 && < 2.0.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Sylin.Koan.Cache:
| Package | Downloads |
|---|---|
|
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.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.Cache.Adapter.Redis
Redis-backed Remote Cache and layered every-node invalidation, using Koan's shared Redis backend without activating Data. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.65 | 165 | 9/13/2026 |
| 1.0.62 | 145 | 9/12/2026 |
| 1.0.59 | 123 | 9/12/2026 |
| 1.0.56 | 126 | 9/10/2026 |
| 1.0.52 | 126 | 9/10/2026 |
| 1.0.47 | 128 | 9/9/2026 |
| 1.0.43 | 123 | 9/9/2026 |
| 1.0.39 | 141 | 9/9/2026 |
| 1.0.32 | 130 | 9/9/2026 |
| 1.0.30 | 146 | 9/9/2026 |
| 1.0.25 | 131 | 9/5/2026 |
| 1.0.24 | 149 | 8/30/2026 |
| 1.0.23 | 131 | 8/30/2026 |
| 1.0.22 | 126 | 8/28/2026 |
| 1.0.21 | 127 | 8/28/2026 |
| 1.0.20 | 134 | 8/28/2026 |
| 1.0.19 | 120 | 8/28/2026 |
| 1.0.18 | 132 | 8/28/2026 |
| 1.0.17 | 136 | 8/27/2026 |
| 1.0.12 | 105 | 8/27/2026 |