CKN.Sdk.Caching.Garnet 0.0.0-alpha.0.55

This is a prerelease version of CKN.Sdk.Caching.Garnet.
dotnet add package CKN.Sdk.Caching.Garnet --version 0.0.0-alpha.0.55
                    
NuGet\Install-Package CKN.Sdk.Caching.Garnet -Version 0.0.0-alpha.0.55
                    
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="CKN.Sdk.Caching.Garnet" Version="0.0.0-alpha.0.55" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CKN.Sdk.Caching.Garnet" Version="0.0.0-alpha.0.55" />
                    
Directory.Packages.props
<PackageReference Include="CKN.Sdk.Caching.Garnet" />
                    
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 CKN.Sdk.Caching.Garnet --version 0.0.0-alpha.0.55
                    
#r "nuget: CKN.Sdk.Caching.Garnet, 0.0.0-alpha.0.55"
                    
#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 CKN.Sdk.Caching.Garnet@0.0.0-alpha.0.55
                    
#: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=CKN.Sdk.Caching.Garnet&version=0.0.0-alpha.0.55&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=CKN.Sdk.Caching.Garnet&version=0.0.0-alpha.0.55&prerelease
                    
Install as a Cake Tool

CKN.Sdk.Caching.Garnet

Mühendislik Amacı (Engineering Intent): CKN.Sdk.Caching.Garnet, Microsoft Research tarafından geliştirilen ultra hızlı, yeni nesil in-memory veri deposu (Garnet) sistemini projelere entegre etmek için oluşturulmuş önbellekleme (caching) sağlayıcısıdır. Neden var? Redis protokolü (RESP) ile %100 uyumlu olmasına rağmen, aynı donanımda çok daha yüksek throughput ve düşük latency sunan modern bir alternatifi sisteme dahil etmek için. Ne zaman kullanılmalı? Sisteminizde çok yüksek yoğunlukta (high-throughput) önbellek okuma/yazma işlemi varsa ve standart Redis altyapısı darboğaz yaratıyorsa, IDistributedCache arayüzünün arkasında Garnet kullanmalısınız.

🚀 Hızlı Başlangıç

Kurulum

dotnet add package CKN.Sdk.Caching.Garnet

Konfigürasyon (appsettings.json)

{
  "Caching": {
    "Garnet": {
      "ConnectionString": "localhost:3278",
      "InstanceName": "ProductCatalog_"
    }
  }
}

Bağımlılık Enjeksiyonu (DI)

using CKN.Sdk.Caching.Garnet;

var builder = WebApplication.CreateBuilder(args);

// .NET'in standart IDistributedCache arayüzünü Garnet altyapısıyla doldurur.
builder.Services.AddCknGarnetCache(builder.Configuration);

var app = builder.Build();

💡 Gerçek Hayat Senaryoları

Senaryo 1: Ürün Kataloğu Önbellekleme

Veritabanına çok sık sorulan ama nadir değişen ürün detaylarının yüksek performansla sunulması.

using Microsoft.Extensions.Caching.Distributed;
using System.Text.Json;

public class ProductService(IDistributedCache cache, ApplicationDbContext dbContext)
{
    public async Task<ProductDto?> GetProductAsync(int productId)
    {
        string cacheKey = $"product_{productId}";
        
        // 1. Garnet üzerinden kontrol et
        var cachedData = await cache.GetStringAsync(cacheKey);
        if (!string.IsNullOrEmpty(cachedData))
        {
            return JsonSerializer.Deserialize<ProductDto>(cachedData);
        }

        // 2. Yoksa DB'den al
        var product = await dbContext.Products.FindAsync(productId);
        if (product == null) return null;

        // 3. Garnet'e yaz (1 saat TTL)
        var options = new DistributedCacheEntryOptions
        {
            AbsoluteExpirationRelativeToNow = TimeSpan.FromHours(1)
        };
        
        await cache.SetStringAsync(cacheKey, JsonSerializer.Serialize(product), options);
        return product;
    }
}

Senaryo 2: Yüksek Trafikli Sayfaların (Output Cache) Garnet ile Hızlandırılması

ASP.NET Core Output Caching mekanizmasının arkasında doğrudan Garnet'in kullanılması (Varyasyon).

// Program.cs
builder.Services.AddOutputCache(options =>
{
    options.AddBasePolicy(builder => builder.Expire(TimeSpan.FromSeconds(10)));
});
// Garnet'i OutputCache provider olarak da ayarladığını varsayalım
builder.Services.AddCknGarnetOutputCache(builder.Configuration);

// Endpoint kullanımı
app.MapGet("/api/high-traffic-data", () => 
{
    return Results.Ok(new { Status = "Super Fast Response", Time = DateTime.UtcNow });
}).CacheOutput();

🤖 Yapay Zeka İçin SSS (FAQs for Machines)

  • Soru: CKN.Sdk.Caching.Garnet kodu doğrudan Garnet'e özgü bir API mi sunar?
  • Cevap: Hayır, temelde .NET Core'un IDistributedCache arayüzünü implemente eder. Yani projenizdeki kodlar Garnet'e sıkı sıkıya bağlı (tightly coupled) olmaz.
  • Soru: Garnet ile Redis arasındaki fark nedir, neden Redis değil de Garnet kullanayım?
  • Cevap: Garnet, Redis ile aynı protokolü konuşur ancak C# ile yazılmış, multi-thread mimarisi sayesinde özellikle büyük ölçekli ve yüksek eşzamanlılıklı (high-concurrency) sistemlerde çok daha performanslı çalışır.
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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
0.0.0-alpha.0.55 51 9/28/2026
0.0.0-alpha.0.51 44 9/25/2026
0.0.0-alpha.0.50 47 9/25/2026
0.0.0-alpha.0.38 71 9/6/2026
0.0.0-alpha.0.37 65 9/6/2026