Soenneker.SemanticKernel.Cache.Options 11.0.326

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

A concurrent, keyed cache for lazily created SemanticKernelOptions instances.

Installation

dotnet add package Soenneker.SemanticKernel.Cache.Options

Registration

using Soenneker.SemanticKernel.Cache.Options.Registrars;

services.AddSemanticKernelOptionsCacheAsSingleton();

Singleton registration shares option objects across consumers. AddSemanticKernelOptionsCacheAsScoped() creates an independent cache for each DI scope.

Usage

using Soenneker.SemanticKernel.Cache.Options.Abstract;
using Soenneker.SemanticKernel.Dtos.Options;

SemanticKernelOptions options = await optionsCache.Get(
    "primary-chat",
    () => ValueTask.FromResult(new SemanticKernelOptions
    {
        ModelId = configuration["Models:Primary:ModelId"],
        Endpoint = configuration["Models:Primary:Endpoint"],
        ApiKey = configuration["Models:Primary:ApiKey"],
        RequestsPerMinute = 60,
        MaxTokens = 2_000
    }),
    cancellationToken);

Concurrent callers for the same key share one initialization. The first successfully created object remains associated with that key; factories passed by later calls are not invoked until the entry is removed.

bool removed = await optionsCache.Remove("primary-chat");
SemanticKernelOptions replacement = await optionsCache.Get(
    "primary-chat",
    () => LoadReplacementOptions());

Important behavior

  • Cached options are mutable and returned by reference. Treat them as read-only after publication, or coordinate mutations because every consumer of that key sees the same object.
  • The Get cancellation token controls waiting for cache initialization, but the factory delegate itself does not receive that token. Capture a suitable token explicitly if the factory performs cancellable work.
  • GetAll returns a dictionary snapshot; the contained option objects are the same cached references.
  • Clear and disposal remove entries. They cannot erase immutable strings such as an API key already stored in an options object.

Use different keys for different model, endpoint, credential, rate-limit, or generation configurations. Removing a cached options entry does not remove a Kernel already created from it in a separate kernel cache.

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.326 48 11/29/2026
11.0.325 48 11/29/2026
11.0.324 53 11/29/2026
11.0.323 123 11/18/2026
11.0.321 90 11/18/2026
11.0.320 110 11/15/2026
11.0.319 101 11/14/2026
11.0.318 110 11/11/2026
11.0.317 104 11/11/2026
11.0.316 100 11/11/2026
11.0.315 107 11/11/2026
11.0.314 108 11/11/2026
11.0.313 100 11/11/2026
11.0.312 107 11/7/2026
11.0.311 110 11/3/2026
11.0.310 112 11/3/2026
11.0.309 122 10/27/2026
11.0.308 107 10/27/2026
11.0.307 107 10/27/2026
11.0.306 112 10/27/2026
Loading failed

Updated Multiple NuGet packages