Soenneker.SemanticKernel.Cache
4.0.830
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.SemanticKernel.Cache --version 4.0.830
NuGet\Install-Package Soenneker.SemanticKernel.Cache -Version 4.0.830
<PackageReference Include="Soenneker.SemanticKernel.Cache" Version="4.0.830" />
<PackageVersion Include="Soenneker.SemanticKernel.Cache" Version="4.0.830" />
<PackageReference Include="Soenneker.SemanticKernel.Cache" />
paket add Soenneker.SemanticKernel.Cache --version 4.0.830
#r "nuget: Soenneker.SemanticKernel.Cache, 4.0.830"
#:package Soenneker.SemanticKernel.Cache@4.0.830
#addin nuget:?package=Soenneker.SemanticKernel.Cache&version=4.0.830
#tool nuget:?package=Soenneker.SemanticKernel.Cache&version=4.0.830
Soenneker.SemanticKernel.Cache
A concurrent, keyed cache that creates and reuses Microsoft Semantic Kernel Kernel instances.
Installation
dotnet add package Soenneker.SemanticKernel.Cache
Registration
using Soenneker.SemanticKernel.Cache.Registrars;
services.AddSemanticKernelCacheAsSingleton();
Singleton registration shares kernels across the application. AddSemanticKernelCacheAsScoped() instead creates an independent cache per DI scope and clears it when that scope is disposed.
Creating a kernel
using Microsoft.SemanticKernel;
using Soenneker.SemanticKernel.Cache.Abstract;
using Soenneker.SemanticKernel.Dtos.Options;
var options = new SemanticKernelOptions
{
ModelId = "chat-model",
Endpoint = "https://model.example.com",
ApiKey = configuration["Models:ApiKey"],
KernelFactory = static (options, cancellationToken) =>
{
IKernelBuilder builder = Kernel.CreateBuilder();
// Add the connector required by your application to builder here.
return ValueTask.FromResult(builder);
},
ConfigureBuilder = builder =>
{
// Register plugins or services before Build(), if needed.
},
ConfigureKernel = async (kernel, cancellationToken) =>
{
// Perform asynchronous post-build configuration, if needed.
await ValueTask.CompletedTask;
}
};
Kernel kernel = await cache.Get("primary-chat", options, cancellationToken);
KernelFactory produces the builder. ConfigureBuilder runs before Build(), and ConfigureKernel runs after the kernel is built. If no factory is supplied, the cache builds an empty Kernel.CreateBuilder(); connector-specific options such as ModelId, Endpoint, and ApiKey are not applied automatically.
Key behavior
The ID is the cache identity. Concurrent requests for the same ID share one initialization, and subsequent calls return that kernel. The options passed during the first successful creation win; later options for the same ID do not reconfigure the existing kernel. Use distinct IDs for distinct configurations.
Kernel sameKernel = await cache.Get("primary-chat", options, cancellationToken);
bool removed = await cache.Remove("primary-chat", cancellationToken);
Kernel rebuilt = await cache.Get("primary-chat", replacementOptions, cancellationToken);
Init and Get both initialize on first access and return the cached instance. GetSync blocks while performing the same operation; prefer the asynchronous API when a factory or post-build configuration can perform asynchronous work.
Remove, Clear, and cache disposal remove and dispose cached kernels through the underlying singleton dictionary. Do not continue using a kernel after its key has been removed or its cache has been disposed. GetAll returns the initialized kernels as a dictionary snapshot for inspection; it does not initialize missing keys.
| 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
- Microsoft.SemanticKernel (>= 1.80.1)
- Soenneker.Dictionaries.Singletons (>= 4.0.92)
- Soenneker.SemanticKernel.Dtos.Options (>= 4.0.107)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Soenneker.SemanticKernel.Cache:
| Package | Downloads |
|---|---|
|
Soenneker.SemanticKernel.Pool
Manages a pool of Semantic Kernel instances with per-entry rate limiting. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.833 | 118 | 9/5/2026 |
| 4.0.832 | 94 | 9/4/2026 |
| 4.0.831 | 134 | 9/4/2026 |
| 4.0.830 | 45 | 9/4/2026 |
| 4.0.829 | 102 | 9/4/2026 |
| 4.0.828 | 100 | 9/3/2026 |
| 4.0.827 | 282 | 8/31/2026 |
| 4.0.826 | 202 | 8/31/2026 |
| 4.0.825 | 126 | 8/31/2026 |
| 4.0.824 | 129 | 8/31/2026 |
| 4.0.823 | 137 | 8/30/2026 |
| 4.0.822 | 82 | 8/30/2026 |
| 4.0.821 | 280 | 8/30/2026 |
| 4.0.820 | 202 | 8/30/2026 |
| 4.0.819 | 149 | 8/30/2026 |
| 4.0.818 | 189 | 8/30/2026 |
| 4.0.817 | 83 | 8/29/2026 |
| 4.0.816 | 128 | 8/29/2026 |
| 4.0.815 | 400 | 8/26/2026 |
| 4.0.814 | 156 | 8/26/2026 |
Updated Multiple NuGet packages