-
Notifications
You must be signed in to change notification settings - Fork 0
Providers
CacheWeave ships eight provider packages. Each registers against ICacheProviderInner — the core library wraps it transparently with optional compression.
dotnet add package CacheWeave.Redisusing CacheWeave.Redis.Extensions;
// Connection string
builder.Services.AddCacheWeaveRedis("localhost:6379");
// With SSL (Azure Cache for Redis)
builder.Services.AddCacheWeaveRedis(
"my-cache.redis.cache.windows.net:6380,ssl=true,password=...,abortConnect=false");
// Reuse an existing IConnectionMultiplexer
builder.Services.AddSingleton<IConnectionMultiplexer>(
_ => ConnectionMultiplexer.Connect("localhost:6379"));
builder.Services.AddCacheWeaveRedis(
sp => sp.GetRequiredService<IConnectionMultiplexer>());RemoveByPrefix: Supported via Redis SCAN + DEL. Safe for large keyspaces — scans and deletes in batches of 250.
dotnet add package CacheWeave.InMemoryusing CacheWeave.InMemory.Extensions;
builder.Services.AddCacheWeaveInMemory();
// With custom MemoryCacheOptions
builder.Services.AddCacheWeaveInMemory(opts =>
{
opts.SizeLimit = 1024; // max entries
});RemoveByPrefix: Supported via in-process prefix scan.
Use this for development, testing, or single-instance deployments where distributed caching is not required.
dotnet add package CacheWeave.DistributedCacheWraps any IDistributedCache implementation (e.g. Microsoft.Extensions.Caching.StackExchangeRedis, Microsoft.Extensions.Caching.SqlServer) so it can be used as a CacheWeave provider.
using CacheWeave.DistributedCache.Extensions;
// No prefix invalidation — IDistributedCache only
builder.Services.AddStackExchangeRedisCache(opts =>
opts.Configuration = "localhost:6379");
builder.Services.AddCacheWeaveDistributedCache();
// With prefix invalidation via IConnectionMultiplexer (connection string)
builder.Services.AddCacheWeaveDistributedCache("localhost:6379");
// With prefix invalidation via an existing IConnectionMultiplexer
builder.Services.AddSingleton<IConnectionMultiplexer>(
_ => ConnectionMultiplexer.Connect("localhost:6379"));
builder.Services.AddCacheWeaveDistributedCache(
sp => sp.GetRequiredService<IConnectionMultiplexer>());RemoveByPrefix: Supported only when an IConnectionMultiplexer is provided — uses Redis SCAN + DEL in batches of 250 across all endpoints. Throws InvalidOperationException if called without a multiplexer.
Use this provider when your project already registers
IDistributedCacheand you want CacheWeave to share the same backing store without adding a second Redis connection.
dotnet add package CacheWeave.SQLiteusing CacheWeave.SQLite.Extensions;
builder.Services.AddCacheWeaveSQLite("Data Source=cache.db");RemoveByPrefix: Supported via DELETE WHERE key LIKE 'prefix%'.
Suitable for edge deployments, embedded devices, or CI environments without Redis.
dotnet add package CacheWeave.DynamoDBusing CacheWeave.DynamoDB.Extensions;
using Amazon.DynamoDBv2;
builder.Services.AddAWSService<IAmazonDynamoDB>();
builder.Services.AddCacheWeaveDynamoDB(tableName: "CacheWeaveEntries");The table must have a key (String) partition key and a ttl (Number) attribute with DynamoDB TTL enabled.
RemoveByPrefix: Not supported — throws NotSupportedException. Use exact key eviction only.
dotnet add package CacheWeave.NCacheusing CacheWeave.NCache.Extensions;
builder.Services.AddCacheWeaveNCache(cacheName: "MyCache");RemoveByPrefix: Not supported — throws NotSupportedException.
dotnet add package CacheWeave.Memcachedusing CacheWeave.Memcached.Extensions;
builder.Services.AddCacheWeaveMemcached(opts =>
{
opts.Servers.Add(new Server { Address = "localhost", Port = 11211 });
});RemoveByPrefix: Not supported — Memcached has no key enumeration API.
dotnet add package CacheWeave.Fasterusing CacheWeave.Faster.Extensions;
builder.Services.AddCacheWeaveFaster(storagePath: "/tmp/faster-cache");RemoveByPrefix: Not supported.
FASTER KV is optimised for extremely high throughput on local NVMe storage. Suitable for single-instance, latency-sensitive workloads.
| Provider | Distributed | RemoveByPrefix |
Persistence | Best For |
|---|---|---|---|---|
| Redis | Yes | Yes | Optional (AOF/RDB) | Production, multi-instance |
| InMemory | No | Yes | No | Dev, test, single-instance |
| DistributedCache | Depends on backing store | With multiplexer only | Depends on backing store | Reuse existing IDistributedCache
|
| SQLite | No | Yes | Yes | Edge, embedded |
| DynamoDB | Yes | No | Yes | AWS-native, serverless |
| NCache | Yes | No | Yes | .NET enterprise |
| Memcached | Yes | No | No | Simple distributed cache |
| FASTER | No | No | Yes | Ultra-high throughput |
Implement ICacheProvider (or ICacheProviderInner) and register it:
public class MyCustomProvider : ICacheProviderInner
{
public Task<string?> GetAsync(string key, CancellationToken ct = default) { ... }
public Task SetAsync(string key, string value, TimeSpan? expiry = null, CancellationToken ct = default) { ... }
public Task RemoveAsync(string key, CancellationToken ct = default) { ... }
public Task RemoveByPrefixAsync(string prefix, CancellationToken ct = default) { ... }
}
// Register
builder.Services.AddCacheWeave();
builder.Services.AddSingleton<ICacheProviderInner, MyCustomProvider>();