Rask.Cache 0.20.1-alpha.0.212

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

Already running Redis?

ICache works over any IDistributedCache, so point it at the one you have — no CacheEntry table, no purge worker, no migration:

builder.Services.AddStackExchangeRedisCache(o => o.Configuration = "localhost:6379");
builder.Services.AddRaskCache();   // no <AppDbContext>

There is deliberately no Rask.Cache.Redis package — Microsoft.Extensions.Caching.StackExchangeRedis is the standard .NET API for this. The overload takes no CacheOptions, because both of them are implemented by the database-backed store and would silently do nothing against another one.

Trim / AOT: the typed GetOrAddAsync<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 (2)

Showing the top 2 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 /_rask 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.

Rask

The one reference a Rask application needs, server or browser. On net10.0 it brings the ASP.NET host plus every battery — database, mediator, background jobs, transactional email, cache, outbox, operator dashboard, durable logs, Web Push, and SQLite snapshots and continuous backup — with RaskApp.Create(args) as the entry point. On net10.0-browser it brings the WebAssembly host, the source-generated mediator, the query cache and remote dispatch. Everything referenced is wired and on; app.Configure(c => c.Jobs.Off()) is how an app does without one. Reference Rask.Server for a lean host with no database.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.20.1-alpha.0.227 0 9/4/2026
0.20.1-alpha.0.226 0 9/4/2026
0.20.1-alpha.0.225 0 9/4/2026
0.20.1-alpha.0.224 0 9/4/2026
0.20.1-alpha.0.223 0 9/4/2026
0.20.1-alpha.0.221 0 9/4/2026
0.20.1-alpha.0.220 0 9/4/2026
0.20.1-alpha.0.217 0 9/4/2026
0.20.1-alpha.0.216 0 9/4/2026
0.20.1-alpha.0.215 29 9/3/2026
0.20.1-alpha.0.213 26 9/3/2026
0.20.1-alpha.0.212 30 9/3/2026
0.20.1-alpha.0.211 36 9/3/2026
0.20.1-alpha.0.210 35 9/3/2026
0.20.1-alpha.0.209 35 9/2/2026
0.20.1-alpha.0.208 30 9/2/2026
0.20.1-alpha.0.207 41 9/2/2026
0.20.1-alpha.0.206 35 9/2/2026
0.20.1-alpha.0.204 42 9/2/2026
0.20.0 114 8/6/2026
Loading failed