Cachula 0.1.0-beta.1
dotnet add package Cachula --version 0.1.0-beta.1
NuGet\Install-Package Cachula -Version 0.1.0-beta.1
<PackageReference Include="Cachula" Version="0.1.0-beta.1" />
<PackageVersion Include="Cachula" Version="0.1.0-beta.1" />
<PackageReference Include="Cachula" />
paket add Cachula --version 0.1.0-beta.1
#r "nuget: Cachula, 0.1.0-beta.1"
#:package Cachula@0.1.0-beta.1
#addin nuget:?package=Cachula&version=0.1.0-beta.1&prerelease
#tool nuget:?package=Cachula&version=0.1.0-beta.1&prerelease
<div align="center">
Cachula
</div>
<div align="center">
</div>
Cachula is a flexible, multi-layer caching library for .NET, designed for modern distributed applications. It supports in-memory and distributed cache layers, cache stampede protection, and seamless integration with dependency injection. Cachula is inspired by the best practices of modern caching libraries, with a special focus on efficient bulk operations.
Key Features
- Multi-layer caching: Compose multiple cache layers (e.g., memory, Redis).
- Bulk operations: Native support for efficient batch get/set/remove operations for multiple keys.
- Cache stampede protection: Prevents multiple concurrent loads for the same key(s) using single-flight logic.
- Null/miss handling: Distinguishes between cache misses and null values.
- Dependency injection ready: Easy to add to your DI container.
- Extensible: Plug in your own cache layers or stampede protection strategies.
Why Cachula?
Cachula is designed for high-throughput, data-driven .NET applications that need to:
- Minimize round-trips to slow data sources.
- Efficiently cache and retrieve large numbers of items at once.
- Avoid cache stampede.
- Compose multiple cache layers for optimal performance and reliability.
Unique advantage: Unlike most caching libraries, Cachula natively supports working with multiple keys at once, making it ideal for batch-oriented scenarios.
Quick Start
1. Register Cachula in DI
services.AddMemoryCache();
services.PutOnCachula()
.WithMemoryCache(); // Adds in-memory cache layer
// Optionally add a distributed cache layer (e.g., Redis)
services.WithDistributedCache(new CachulaRedisCache(redisDatabase));
2. Use ICachulaCache in your services
public class MyService
{
private readonly ICachulaCache _cache;
public MyService(ICachulaCache cache) => _cache = cache;
public async Task<MyData?> GetDataAsync(string key)
{
return await _cache.GetOrSetAsync(
key,
async ct => await LoadFromDbAsync(key, ct),
TimeSpan.FromMinutes(10)
);
}
public async Task<IReadOnlyCollection<MyData>> GetManyAsync(IEnumerable<string> keys)
{
return await _cache.GetOrSetManyAsync(
keys,
async (missingKeys, ct) => await LoadManyFromDbAsync(missingKeys, ct),
TimeSpan.FromMinutes(10)
);
}
}
Advanced Usage
Custom Cache Layers
Implement ICacheLayer
to add your own cache backend.
Distributed Cache
Use CachulaRedisCache
for Redis support:
var redisCache = new CachulaRedisCache(redisDatabase);
services.WithDistributedCache(redisCache);
Null and Miss Handling
- Null: Value was found in cache and is
null
. - Missed: Value was not found in cache.
FAQ
Q: How is Cachula different from FusionCache or CacheTower?
- Cachula is focused on batch/bulk operations and multi-layer composition, with a simple, extensible API.
- It is designed for scenarios where you need to cache and retrieve many items at once efficiently.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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 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 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Extensions.Caching.Abstractions (>= 9.0.0 && < 10.0.0)
- Microsoft.Extensions.DependencyInjection (>= 9.0.0 && < 10.0.0)
- System.Text.Json (>= 8.0.5 && < 9.0.0)
-
net8.0
- Microsoft.Extensions.Caching.Abstractions (>= 9.0.0 && < 10.0.0)
- Microsoft.Extensions.DependencyInjection (>= 9.0.0 && < 10.0.0)
-
net9.0
- Microsoft.Extensions.Caching.Abstractions (>= 9.0.0 && < 10.0.0)
- Microsoft.Extensions.DependencyInjection (>= 9.0.0 && < 10.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Cachula:
Package | Downloads |
---|---|
Cachula.Redis
Redis provider for Cachula: multi-layer caching with Redis backend, cache stampede protection, bulk ops and DI integration. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
0.1.0-beta.1 | 87 | 8/10/2025 |
Initial beta with netstandard2.0/net8.0/net9.0 targets.