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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Sylin.Koan.Cache" Version="0.20.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Sylin.Koan.Cache" Version="0.20.4" />
                    
Directory.Packages.props
<PackageReference Include="Sylin.Koan.Cache" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Sylin.Koan.Cache --version 0.20.4
                    
#r "nuget: Sylin.Koan.Cache, 0.20.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Sylin.Koan.Cache@0.20.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Sylin.Koan.Cache&version=0.20.4
                    
Install as a Cake Addin
#tool nuget:?package=Sylin.Koan.Cache&version=0.20.4
                    
Install as a Cake Tool

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.

Version Downloads Last Updated
0.20.4 103 7/24/2026
0.20.3 132 7/22/2026
0.20.2 169 7/21/2026
0.17.0 142 6/12/2026
0.8.0 140 5/16/2026