Soenneker.SemanticKernel.Cache 11.0.929

Prefix Reserved
dotnet add package Soenneker.SemanticKernel.Cache --version 11.0.929
                    
NuGet\Install-Package Soenneker.SemanticKernel.Cache -Version 11.0.929
                    
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.929" />
                    
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.929" />
                    
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.929
                    
#r "nuget: Soenneker.SemanticKernel.Cache, 11.0.929"
                    
#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.929
                    
#: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.929
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.SemanticKernel.Cache&version=11.0.929
                    
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.929 0 12/3/2026
11.0.928 0 12/3/2026
11.0.927 0 12/3/2026
11.0.926 0 12/2/2026
11.0.925 11 12/2/2026
11.0.924 11 12/2/2026
11.0.923 92 12/2/2026
11.0.922 95 12/2/2026
11.0.921 126 12/1/2026
11.0.920 114 12/1/2026
11.0.919 127 12/1/2026
11.0.918 135 12/1/2026
11.0.917 122 12/1/2026
11.0.916 189 11/30/2026
11.0.915 197 11/29/2026
11.0.914 177 11/29/2026
11.0.913 429 11/18/2026
11.0.912 113 11/18/2026
11.0.910 218 11/18/2026
11.0.909 436 11/15/2026
Loading failed

Updated Soenneker.Dictionaries.Singletons to 11.0.159