Rask.Cache 0.19.0

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Rask.Cache --version 0.19.0
                    
NuGet\Install-Package Rask.Cache -Version 0.19.0
                    
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="Rask.Cache" Version="0.19.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Rask.Cache" Version="0.19.0" />
                    
Directory.Packages.props
<PackageReference Include="Rask.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 Rask.Cache --version 0.19.0
                    
#r "nuget: Rask.Cache, 0.19.0"
                    
#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 Rask.Cache@0.19.0
                    
#: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=Rask.Cache&version=0.19.0
                    
Install as a Cake Addin
#tool nuget:?package=Rask.Cache&version=0.19.0
                    
Install as a Cake Tool

Rask.Cache

A developer-facing cache for a Rask app — stored in the app's own database, with no broker or Redis.

  • Implements the standard IDistributedCache, so it drops straight into ASP.NET session state, output caching, and anything else built on the abstraction.
  • A typed ICache convenience layer adds GetOrCreateAsync<T> read-through, plus GetAsync<T> / SetAsync<T> / RemoveAsync (JSON under the hood).
  • Entries carry absolute and sliding expirations; a read renews a sliding entry and an expired entry is evicted lazily. A background CachePurger sweeps expired rows on an interval.

Use

// Program.cs
builder.Services.AddRaskCache<AppDbContext>();

// AppDbContext.OnModelCreating:  modelBuilder.AddRaskCache();
// then:  rask db add AddCache && rask db update
// read-through: the factory runs once on a miss, then the value is served from the DB.
var rates = await cache.GetOrCreateAsync(
    $"rates:{date:yyyyMMdd}",
    ct => exchange.FetchRatesAsync(date, ct),
    new DistributedCacheEntryOptions { SlidingExpiration = TimeSpan.FromMinutes(10) });

Register your context as an IDbContextFactory<AppDbContext> (Rask Server sessions are long-lived) and run one purger per app — SQLite is single-writer.

Trim / AOT: the typed GetOrCreateAsync<T>/GetAsync<T>/SetAsync<T> overloads use reflection-based System.Text.Json. In a trimmed or AOT app, use the JsonTypeInfo<T> overloads with a source-generated JsonSerializerContext. The IDistributedCache (byte[]) surface is fully trim-safe.

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 (1)

Showing the top 1 NuGet packages that depend on Rask.Cache:

Package Downloads
Rask.Dashboard

A built-in operator dashboard for the Rask One Person Framework batteries. Mounts at /_ops and shows the outbox, background jobs, queued mail and cache from the application's own database — queue depth, dead letters, the errors behind them, stored email previews, the recurring-job schedule, SQLite pragmas and backup status. A live log tail is built in, and becomes a searchable history when Rask.Logging is installed. Panels appear only for the batteries the app actually registered. Protected by an authorization policy that fails closed outside Development.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.19.1-alpha.0.62 0 8/5/2026
0.19.1-alpha.0.57 0 8/5/2026
0.19.1-alpha.0.51 0 8/5/2026
0.19.1-alpha.0.43 16 8/5/2026
0.19.1-alpha.0.42 25 8/5/2026
0.19.1-alpha.0.40 24 8/5/2026
0.19.1-alpha.0.38 22 8/5/2026
0.19.1-alpha.0.32 24 8/5/2026
0.19.1-alpha.0.31 30 8/4/2026
0.19.1-alpha.0.30 32 8/4/2026
0.19.1-alpha.0.28 28 8/4/2026
0.19.1-alpha.0.25 27 8/4/2026
0.19.1-alpha.0.24 33 8/4/2026
0.19.1-alpha.0.23 32 8/4/2026
0.19.1-alpha.0.14 40 8/3/2026
0.19.1-alpha.0.13 38 8/3/2026
0.19.1-alpha.0.12 39 8/3/2026
0.19.1-alpha.0.11 39 8/3/2026
0.19.1-alpha.0.6 35 8/3/2026
0.19.0 103 7/20/2026
Loading failed