MERSELSDK.Caching 0.1.0-preview.20260710002836

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

MERSELSDK.Caching

Genel Bakış

MERSELSDK.Caching modülü, .NET uygulamaları için esnek ve genişletilebilir bir önbellekleme (caching) altyapısı sunar. Hem dağıtık (Redis gibi) hem de bellek içi (in-memory) önbellek desteği sağlar. Modül, kolayca entegre edilebilen arayüzler ve servisler ile önbellek yönetimini standartlaştırır.

Özellikler

  • Dağıtık önbellek (Redis) ve bellek içi önbellek desteği
  • ICacheService arayüzü ile soyutlama
  • Kolay DI (Dependency Injection) entegrasyonu
  • Özelleştirilebilir önbellek anahtarı ve yaşam süresi yönetimi
  • Gelişmiş get/set ve get-or-create fonksiyonları
  • .NET IDistributedCache ve IMemoryCache ile uyumlu

Kurulum

NuGet üzerinden ekleyin:

dotnet add package MERSELSDK.Caching

Konfigürasyon

Redis Dağıtık Önbellek

appsettings.json dosyanıza aşağıdaki bölümü ekleyin:

{
  "DistributedCache": {
    "Configuration": "localhost:6379",
    "InstanceName": "myapp_cache_"
  }
}

Kullanım

Servislerin Kaydı

Program.cs dosyanızda aşağıdaki gibi servisleri kaydedin:

using Microsoft.Extensions.DependencyInjection;

var builder = WebApplication.CreateBuilder(args);

// Redis ile dağıtık önbellek
builder.Services.AddRedisDistributedCache(options =>
{
    options.Configuration = builder.Configuration["DistributedCache:Configuration"];
    options.InstanceName = builder.Configuration["DistributedCache:InstanceName"];
});

// veya sadece bellek içi önbellek
builder.Services.AddInMemoryCacheService();

Temel Kullanım

ICacheService arayüzünü kullanarak önbelleğe veri ekleyebilir, okuyabilir veya get-or-create mantığıyla çalışabilirsiniz:

using MERSELSDK.Caching.Interfaces;

public class SampleService
{
    private readonly ICacheService _cacheService;

    public SampleService(ICacheService cacheService)
    {
        _cacheService = cacheService;
    }

    public async Task<string> GetOrSetExampleAsync()
    {
        var cacheKey = "sample_key";
        var value = await _cacheService.GetOrCreateAsync(
            cacheKey,
            async () => await GetDataFromSourceAsync(),
            new DistributedCacheEntryOptions { SlidingExpiration = TimeSpan.FromMinutes(5) }
        );
        return value;
    }
}

Gelişmiş Kullanım: CacheEntry ile

Kendi CacheEntry tipinizi türeterek anahtar ve yaşam süresi yönetimini merkezi hale getirebilirsiniz:

using MERSELSDK.Caching;

public class UserCacheEntry : CacheEntry
{
    public override string CacheKey => $"user_{UserId}";
    protected override string Template => "user_{UserId}";
    public string UserId { get; set; }

    public override DistributedCacheEntryOptions GetCacheEntryOptions()
    {
        return new DistributedCacheEntryOptions
        {
            AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(10)
        };
    }
}

Ana Sınıflar ve Arayüzler

  • ICacheService: Temel önbellek işlemleri için arayüz.
  • DistributedCacheService: Redis gibi dağıtık önbellek implementasyonu.
  • InMemoryCacheService: Bellek içi önbellek implementasyonu.
  • CacheEntry: Anahtar ve yaşam süresi yönetimi için soyut sınıf.
  • DistributedCacheOptions: Dağıtık önbellek yapılandırma seçenekleri.

Katkıda Bulunma

Katkı sağlamak için issue veya pull request açabilirsiniz.

Lisans

MIT Lisansı ile lisanslanmıştır.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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 was computed.  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.1.0-preview.20260710002836 73 7/10/2026
0.1.0-preview.20260709234905 70 7/9/2026
0.1.0-preview.20260702055213 74 7/2/2026
0.0.1-preview.20260627.112114 62 6/27/2026
0.0.1-preview.20260627.110256 69 6/27/2026