Soenneker.Maf.Cache.Options 11.0.189

Prefix Reserved
dotnet add package Soenneker.Maf.Cache.Options --version 11.0.189
                    
NuGet\Install-Package Soenneker.Maf.Cache.Options -Version 11.0.189
                    
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="Soenneker.Maf.Cache.Options" Version="11.0.189" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Maf.Cache.Options" Version="11.0.189" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Maf.Cache.Options" />
                    
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 Soenneker.Maf.Cache.Options --version 11.0.189
                    
#r "nuget: Soenneker.Maf.Cache.Options, 11.0.189"
                    
#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 Soenneker.Maf.Cache.Options@11.0.189
                    
#: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=Soenneker.Maf.Cache.Options&version=11.0.189
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Maf.Cache.Options&version=11.0.189
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

Soenneker.Maf.Cache.Options

A cache for MafOptions using a SingletonDictionary with support for keyed asynchronous creation.

Install

dotnet add package Soenneker.Maf.Cache.Options

Usage

using Microsoft.Extensions.DependencyInjection;
using Soenneker.Maf.Cache.Options.Abstract;
using Soenneker.Maf.Cache.Options.Registrars;
using Soenneker.Maf.Dtos.Options;

services.AddMafOptionsCacheAsSingleton();

IMafOptionsCache cache = serviceProvider.GetRequiredService<IMafOptionsCache>();

MafOptions options = await cache.Get("primary", static () =>
    ValueTask.FromResult(new MafOptions
    {
        ModelId = "my-model",
        RequestsPerMinute = 60
    }));

The factory runs once for a given key while that entry remains cached. Remove the entry before supplying a replacement factory for the same key.

What you get

  • IMafOptionsCache — A cache for MafOptions using a SingletonDictionary with support for keyed asynchronous creation.
  • MafOptionsCacheRegistrar — Registers IMafOptionsCache as a singleton or scoped service.

API at a glance

API What it does Result / important behavior
IMafOptionsCache.Get(key, optionsFactory, cancellationToken) Gets an existing MafOptions from the cache, or creates and caches one using the provided factory. The cached or newly created MafOptions.
IMafOptionsCache.Remove(key) Removes an entry from the cache. A task representing the asynchronous remove operation.
IMafOptionsCache.GetAll(cancellationToken) Retrieves all cached MafOptions entries, keyed by their cache keys. A dictionary of all keys and their corresponding MafOptions values.
IMafOptionsCache.Clear(cancellationToken) Clears all entries from the cache. A task representing the asynchronous clear operation.
MafOptionsCacheRegistrar.AddMafOptionsCacheAsSingleton(services) Adds IMafOptionsCache as a singleton service. The same service collection, so additional registrations can be chained.
MafOptionsCacheRegistrar.AddMafOptionsCacheAsScoped(services) Adds IMafOptionsCache as a scoped service. The same service collection, so additional registrations can be chained.

Practical notes

  • Use singleton registration to share option objects across scopes, or AddMafOptionsCacheAsScoped() to isolate the cache per scope.
  • The cache returns the same mutable MafOptions instance for a key; coordinate mutations or treat cached values as immutable.
  • Disposing the cache releases its backing singleton dictionary.
Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
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
11.0.189 47 11/15/2026
11.0.188 90 11/11/2026
11.0.187 78 11/11/2026
11.0.186 80 11/11/2026
11.0.185 81 11/11/2026
11.0.184 86 11/11/2026
11.0.183 82 11/11/2026
11.0.182 109 11/7/2026
11.0.181 100 11/3/2026
11.0.180 90 11/3/2026
11.0.179 108 10/30/2026
11.0.178 97 10/27/2026
11.0.177 99 10/27/2026
11.0.176 103 10/26/2026
11.0.172 91 10/26/2026
11.0.171 98 10/26/2026
11.0.170 90 10/26/2026
11.0.169 98 10/26/2026
4.0.168 103 10/24/2026
4.0.167 117 10/15/2026
Loading failed

Update dependency Soenneker.Dictionaries.Singletons to 11.0.141 (#365)