Anarchy.Toolkit.Runtime.Workers.Caching 1.1.1

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

Anarchy.Toolkit.Runtime.Workers.Caching

Part of Anarchy I/O Toolkit, a .NET developer platform · Pillar: Infrastructure · Layer: Runtime · Package catalog

The snapshot refresher: a worker that keeps the typed snapshots of Anarchy.Toolkit.Infrastructure.Caching up to date.

dotnet add package Anarchy.Toolkit.Runtime.Workers.Caching

When to use it

Use it in the job or worker that writes the snapshots readers take from ISnapshotCache<T> (for example a carrier list read by several APIs from Redis). Each snapshot gets a loader that reads its source of truth; one worker calls the loaders on an interval and stores their values. Readers only need Infrastructure.Caching and the shared store's package.

How to use it

public sealed class CarrierListLoader(ICarrierRepository carriers) : ISnapshotLoader<CarrierList>
{
    public async Task<CarrierList> LoadAsync(CancellationToken? cancellationToken = null) =>
        new(await carriers.ListAsync(cancellationToken));
}

services
    .UseModule(new ModuleRedisCache(c => c.GetRequired<RedisCacheOptions>("Redis")), configuration, environment)
    .AddSnapshotCache(new SnapshotCacheOptions<CarrierList> { MaxAge = TimeSpan.FromMinutes(30) })
    .AddSnapshotLoader<CarrierList, CarrierListLoader>(c => new SnapshotLoaderOptions {
        Interval = TimeSpan.FromMinutes(10),
        Timeout = TimeSpan.FromSeconds(30)
    });

AddSnapshotLoader<T, TLoader>(configure) registers, with TryAdd:

  • TLoader as the scoped ISnapshotLoader<T>, resolved from a new scope for every load;
  • the snapshot cache of T and its freshness check as an IHealthCheck (AddSnapshotFreshnessHealthCheck<T>);
  • the refresher worker, once for every loader. Call AddSnapshotRefresher(configure) first to set its options.
SnapshotLoaderOptions Default Effect
Interval 5 minutes Time between two loads of this snapshot
Timeout 1 minute A load still running after it is abandoned (even when the loader ignores its token) and counted as failed
SnapshotRefresherOptions Default Effect
PollInterval 1 second How often the worker checks which snapshots are due
PreloadOnStart true Loads every snapshot while the host starts, before the worker reports started
Worker ResilientWorkerOptions defaults Retry and failure policy of the worker loop itself

Behaviour

  • Parallel. The due snapshots load at the same time, each with its own timeout, so a slow source does not delay the others.
  • Last good snapshot. A failed or timed-out load stores nothing: readers keep the previous snapshot, and the loop goes on. The freshness check reports a snapshot once it is older than its MaxAge.
  • Readiness. The freshness check fails until the first load succeeds. With PreloadOnStart that load happens before the host finishes starting; a failed preload does not stop the host.
  • Telemetry. Each load records snapshot_refresher.load.execution_time and snapshot_refresher.load.execution_count through AppTelemetry, tagged snapshot (the type name), outcome (success, failure or timeout) and success; failures and timeouts are logged with the exception.

See the Infrastructure.Caching README and the toolkit overview.

Releases

See the release notes for the complete release history.

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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.2 45 12/4/2026
1.1.1 51 12/3/2026
1.1.0 53 12/2/2026
1.0.0 60 12/1/2026

## Releases

### 1.1.1

- feat(Automation)!: Scaffold test suites, single-app prefix layouts and multi-trigger Lambda APIs
 > - `anarchy-toolkit scaffold tests <kind> --for <project>` adds a source project reference and its mirrored test folder; generated web applications get dependency-injection tests.
 > - Prefix single-app bootstraps generate one `Apps.<name>` project without a separate Runtime library; `tests/Common` references it, or the outermost library.
 > - API Lambda handlers serve REST API, HTTP API v2 and Application Load Balancer triggers; entry points add the Systems Manager Parameter Store once when they reference `Bootstrap.Aws`.
 > - Worker correlation options, shared auth settings for web applications only, and release notes that render commit bodies as blockquotes.
 >
 > BREAKING CHANGE: generated Lambda handler names and the container Parameter Store configuration differ from earlier scaffolds.

### 1.1.0

- Follows `Bootstrap` 2.2.0 (`ModuleLibBootstrap`).

### 1.0.0

- Add `ISnapshotLoader<T>`, `SnapshotLoaderOptions`, `SnapshotRefresherOptions`, `AddSnapshotLoader<T, TLoader>` and `AddSnapshotRefresher`: one worker loads every registered snapshot on its interval, in parallel and each with its own timeout, preloads on start and keeps the last good snapshot on failure.