Soenneker.SemanticKernel.Cache.Options 11.0.303

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.SemanticKernel.Cache.Options --version 11.0.303
                    
NuGet\Install-Package Soenneker.SemanticKernel.Cache.Options -Version 11.0.303
                    
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.303" />
                    
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.303" />
                    
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.303
                    
#r "nuget: Soenneker.SemanticKernel.Cache.Options, 11.0.303"
                    
#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.303
                    
#: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.303
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.SemanticKernel.Cache.Options&version=11.0.303
                    
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.312 39 11/7/2026
11.0.311 82 11/3/2026
11.0.310 79 11/3/2026
11.0.309 108 10/27/2026
11.0.308 92 10/27/2026
11.0.307 94 10/27/2026
11.0.306 92 10/27/2026
11.0.305 98 10/26/2026
11.0.303 92 10/26/2026
11.0.302 89 10/26/2026
11.0.301 93 10/26/2026
11.0.300 94 10/26/2026
11.0.299 91 10/26/2026
4.0.298 118 10/15/2026
4.0.297 102 10/15/2026
4.0.296 96 10/15/2026
4.0.295 97 10/15/2026
4.0.294 98 10/14/2026
4.0.292 96 10/14/2026
4.0.290 94 10/14/2026
Loading failed

Updated Multiple NuGet packages