MERSELSDK.Caching
0.1.0-preview.20260710002836
dotnet add package MERSELSDK.Caching --version 0.1.0-preview.20260710002836
NuGet\Install-Package MERSELSDK.Caching -Version 0.1.0-preview.20260710002836
<PackageReference Include="MERSELSDK.Caching" Version="0.1.0-preview.20260710002836" />
<PackageVersion Include="MERSELSDK.Caching" Version="0.1.0-preview.20260710002836" />
<PackageReference Include="MERSELSDK.Caching" />
paket add MERSELSDK.Caching --version 0.1.0-preview.20260710002836
#r "nuget: MERSELSDK.Caching, 0.1.0-preview.20260710002836"
#:package MERSELSDK.Caching@0.1.0-preview.20260710002836
#addin nuget:?package=MERSELSDK.Caching&version=0.1.0-preview.20260710002836&prerelease
#tool nuget:?package=MERSELSDK.Caching&version=0.1.0-preview.20260710002836&prerelease
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
ICacheServicearayü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
IDistributedCacheveIMemoryCacheile 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 | Versions 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. |
-
net6.0
- MERSELSDK.Core.Configuration (>= 0.1.0-preview.20260710002836)
- Microsoft.Extensions.Caching.Abstractions (>= 6.0.1)
- Microsoft.Extensions.Caching.Memory (>= 6.0.2)
- Microsoft.Extensions.Caching.StackExchangeRedis (>= 6.0.2)
- Microsoft.Extensions.Configuration (>= 6.0.2)
- Microsoft.Extensions.DependencyInjection (>= 6.0.2)
-
net9.0
- MERSELSDK.Core.Configuration (>= 0.1.0-preview.20260710002836)
- Microsoft.Extensions.Caching.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Caching.Memory (>= 9.0.0)
- Microsoft.Extensions.Caching.StackExchangeRedis (>= 9.0.0)
- Microsoft.Extensions.Configuration (>= 9.0.0)
- Microsoft.Extensions.DependencyInjection (>= 9.0.0)
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 |