Soenneker.SemanticKernel.Cache.Options 4.0.257

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 4.0.257
                    
NuGet\Install-Package Soenneker.SemanticKernel.Cache.Options -Version 4.0.257
                    
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="4.0.257" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.SemanticKernel.Cache.Options" Version="4.0.257" />
                    
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 4.0.257
                    
#r "nuget: Soenneker.SemanticKernel.Cache.Options, 4.0.257"
                    
#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@4.0.257
                    
#: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=4.0.257
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.SemanticKernel.Cache.Options&version=4.0.257
                    
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 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
4.0.273 72 10/6/2026
4.0.272 86 9/30/2026
4.0.271 86 9/30/2026
4.0.270 86 9/29/2026
4.0.269 87 9/29/2026
4.0.268 93 9/25/2026
4.0.267 93 9/25/2026
4.0.266 96 9/25/2026
4.0.265 92 9/24/2026
4.0.264 85 9/24/2026
4.0.263 96 9/17/2026
4.0.262 93 9/16/2026
4.0.261 93 9/16/2026
4.0.260 95 9/16/2026
4.0.259 96 9/16/2026
4.0.258 95 9/15/2026
4.0.257 91 9/15/2026
4.0.256 101 9/13/2026
4.0.255 92 9/13/2026
4.0.254 101 9/12/2026
Loading failed

Update dependency dotnet-sdk to v10.0.401 (#785)