Soenneker.SemanticKernel.Cache 11.0.909

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

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 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 (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
11.0.909 0 11/15/2026
11.0.908 81 11/14/2026
11.0.907 245 11/11/2026
11.0.906 120 11/11/2026
11.0.905 162 11/11/2026
11.0.904 53 11/11/2026
11.0.903 79 11/11/2026
11.0.902 90 11/11/2026
11.0.901 457 11/7/2026
11.0.900 162 11/7/2026
11.0.899 277 11/3/2026
11.0.898 207 11/3/2026
11.0.897 394 10/27/2026
11.0.896 166 10/27/2026
11.0.895 264 10/27/2026
11.0.894 157 10/26/2026
11.0.891 165 10/26/2026
11.0.890 158 10/26/2026
11.0.889 167 10/26/2026
11.0.888 120 10/26/2026
Loading failed

Update dependency Soenneker.Dictionaries.Singletons to 11.0.141 (#1740)