Innovabit.DotNet.Interceptors.Caching.Abstractions
3.0.133
See the version list below for details.
dotnet add package Innovabit.DotNet.Interceptors.Caching.Abstractions --version 3.0.133
NuGet\Install-Package Innovabit.DotNet.Interceptors.Caching.Abstractions -Version 3.0.133
<PackageReference Include="Innovabit.DotNet.Interceptors.Caching.Abstractions" Version="3.0.133" />
<PackageVersion Include="Innovabit.DotNet.Interceptors.Caching.Abstractions" Version="3.0.133" />
<PackageReference Include="Innovabit.DotNet.Interceptors.Caching.Abstractions" />
paket add Innovabit.DotNet.Interceptors.Caching.Abstractions --version 3.0.133
#r "nuget: Innovabit.DotNet.Interceptors.Caching.Abstractions, 3.0.133"
#:package Innovabit.DotNet.Interceptors.Caching.Abstractions@3.0.133
#addin nuget:?package=Innovabit.DotNet.Interceptors.Caching.Abstractions&version=3.0.133
#tool nuget:?package=Innovabit.DotNet.Interceptors.Caching.Abstractions&version=3.0.133
Innovabit.DotNet.Interceptors.Caching.Abstractions
Method-result caching for Innovabit.DotNet.Interceptors
via a [Cache] attribute. This is the provider-agnostic base: it ships the interceptor, the
attribute, the pluggable key generator/serializer and the ICacheStore abstraction. Pick a store
provider to actually cache anything:
Innovabit.DotNet.Interceptors.Caching.Memory— in-process cache on .NET'sIMemoryCache.Innovabit.DotNet.Interceptors.Caching.Redis— distributed cache on Redis (IDistributedCache).
Usage
services
.AddInterceptors()
.AddInMemoryCache() // or .AddRedisCache(o => o.Configuration = "localhost:6379")
.ConfigureCacheDefaults(d => d.DurationSeconds = 60); // optional global defaults
services.AddScopedWithInterception<IPriceService, PriceService>();
public class PriceService : IPriceService
{
// Cached for 30s; a bare [Cache] would inherit the configured defaults.
[Cache(DurationSeconds = 30)]
public Task<decimal> GetQuoteAsync(string symbol) => _api.FetchAsync(symbol);
}
The first call runs the method and stores the result; later calls with the same arguments return
the cached value without invoking the method. Only value-returning methods are cached — void,
Task and ValueTask (no result) are ignored; Task<T>/ValueTask<T> are cached on their
unwrapped result.
[Cache] / CacheDefaults
| Property | Meaning |
|---|---|
DurationSeconds |
Absolute lifetime in seconds. 0 = no absolute expiration. |
SlidingExpirationSeconds |
Expire after this long without a read. 0 = disabled. |
KeyPrefix |
Prefix prepended to the generated key (namespacing per tenant/version/…). |
CacheNullValues |
Whether a null result is cached. Defaults to false. |
Any property left unset on [Cache] inherits from the CacheDefaults configured via
ConfigureCacheDefaults; a property set on the method always wins.
Cache keys
The key is derived per method + argument values, so calls with different arguments are cached
separately and calls with the same arguments share an entry. The default ICacheKeyGenerator hashes
the method signature and the arguments' public state (SHA-256).
Values are read by their runtime type — properties and public fields, nested and derived values
included — so two different values never share an entry because of how they were declared.
[JsonIgnore] members are left out, and a nested CancellationToken too. A value with no readable
state (a class with only private fields, say) is identified by its ToString() when its type
overrides it; otherwise, and always for a Stream, a delegate or a Task, the call fails with an
InvalidOperationException naming the parameter. Mark that parameter [CacheKeyIgnore] if it does
not affect the result, or pass the values that do.
Two kinds of parameter are left out of the key:
CancellationTokenparameters — always ignored (runtime plumbing, not part of a call's identity).- Parameters marked
[CacheKeyIgnore]— opt a specific parameter out of the key when it does not affect the result (a logger, a correlation id, anIProgress<T>callback, …).
// requestId does not change the result, so both calls hit the same cache entry:
[Cache(DurationSeconds = 30)]
public Task<Quote> GetQuoteAsync(string symbol, [CacheKeyIgnore] Guid requestId) => _api.FetchAsync(symbol);
[CacheKeyIgnore] is honoured by the default key generator; a custom generator defines its own
policy. Like other parameter-level attributes it only has an effect while the method is intercepted
(also carries [Cache]) — the bundled analyzer warns (INTX002) when it does not.
When the store fails
A store that throws — Redis is down, an entry no longer deserializes — is treated as a miss: the method runs and its result is returned. Watch for it, or opt out of it, through the defaults:
services.AddInterceptors()
.AddRedisCache(...)
.ConfigureCacheDefaults(o =>
{
o.OnStoreFailure = (key, exception) => logger.LogWarning(exception, "Cache store failed.");
o.ThrowOnStoreFailure = false; // the default; true fails the call instead
});
After a failed read the result is not written either, so an outage costs one store timeout per call rather than two; an entry that could not be deserialized is rewritten.
Flexibility / extension points
Everything is resolved from DI and can be swapped:
ICacheStore— the backing store. Provided by the Memory/Redis packages; implement your own for any backend.ICacheKeyGenerator— how keys are derived. Default: SHA-256 over the method signature + the arguments' public state (ignoringCancellationTokenand[CacheKeyIgnore]parameters). Replace withUseCacheKeyGenerator<T>().ICacheSerializer— how values are serialized for distributed stores. Default:System.Text.Json. Replace withUseCacheSerializer<T>().
Pipeline order
CacheInterceptor runs at InterceptorOrders.Caching (200) — above retry/timeout so a hit
short-circuits the expensive work, below validation so invalid arguments still fail fast. Override
per registration with .Register<CacheInterceptor>(order) / .SetOrder<CacheInterceptor>(order).
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. net11.0 is compatible. |
-
net10.0
- Innovabit.DotNet.Interceptors.Abstractions (>= 3.0.133)
-
net11.0
- Innovabit.DotNet.Interceptors.Abstractions (>= 3.0.133)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on Innovabit.DotNet.Interceptors.Caching.Abstractions:
| Package | Downloads |
|---|---|
|
Innovabit.DotNet.Interceptors.Caching.Memory
In-memory (IMemoryCache) store provider for interceptor-based caching. |
|
|
Innovabit.DotNet.Interceptors.Caching.Redis
Redis (IDistributedCache) store provider for interceptor-based caching. |
|
|
Innovabit.DotNet.Interceptors.All
Meta-package: every interceptor concern in the suite (logging, validation, caching, notifications, telemetry, audit, authorization, rate limiting, coordination, feature gates, transactions, retry/timeout/circuit breaker/fallback) in one reference. Providers are separate packages — pick the ones you use. |
|
|
Innovabit.DotNet.Interceptors.Caching.Hybrid
HybridCache (L1 + L2, with stampede protection) store provider for interceptor-based caching. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.136 | 58 | 12/5/2026 |
| 3.0.135 | 242 | 11/30/2026 |
| 3.0.134 | 137 | 11/30/2026 |
| 3.0.133 | 138 | 11/30/2026 |
| 3.0.132 | 132 | 11/30/2026 |
| 3.0.129 | 150 | 11/30/2026 |
| 3.0.128 | 140 | 11/30/2026 |
| 3.0.127 | 158 | 11/30/2026 |
| 3.0.126 | 146 | 11/30/2026 |
| 3.0.125 | 142 | 11/30/2026 |
| 3.0.124 | 161 | 11/28/2026 |
| 3.0.123 | 141 | 11/28/2026 |
| 3.0.122 | 273 | 11/21/2026 |
| 2.0.121 | 180 | 11/21/2026 |
| 2.0.120 | 169 | 11/21/2026 |
| 2.0.119 | 230 | 11/14/2026 |
| 2.0.118 | 190 | 11/7/2026 |
| 2.0.117 | 200 | 10/31/2026 |
| 2.0.116 | 182 | 10/26/2026 |
| 2.0.115 | 194 | 10/17/2026 |