Soenneker.SemanticKernel.Cache.Options
4.0.257
Prefix Reserved
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
<PackageReference Include="Soenneker.SemanticKernel.Cache.Options" Version="4.0.257" />
<PackageVersion Include="Soenneker.SemanticKernel.Cache.Options" Version="4.0.257" />
<PackageReference Include="Soenneker.SemanticKernel.Cache.Options" />
paket add Soenneker.SemanticKernel.Cache.Options --version 4.0.257
#r "nuget: Soenneker.SemanticKernel.Cache.Options, 4.0.257"
#:package Soenneker.SemanticKernel.Cache.Options@4.0.257
#addin nuget:?package=Soenneker.SemanticKernel.Cache.Options&version=4.0.257
#tool nuget:?package=Soenneker.SemanticKernel.Cache.Options&version=4.0.257
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
Getcancellation 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. GetAllreturns a dictionary snapshot; the contained option objects are the same cached references.Clearand 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 | Versions 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. |
-
net10.0
- Soenneker.Dictionaries.Singletons (>= 4.0.102)
- Soenneker.SemanticKernel.Dtos.Options (>= 4.0.111)
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 |
Update dependency dotnet-sdk to v10.0.401 (#785)