redb.Route.Cache
4.0.1
Prefix Reserved
dotnet add package redb.Route.Cache --version 4.0.1
NuGet\Install-Package redb.Route.Cache -Version 4.0.1
<PackageReference Include="redb.Route.Cache" Version="4.0.1" />
<PackageVersion Include="redb.Route.Cache" Version="4.0.1" />
<PackageReference Include="redb.Route.Cache" />
paket add redb.Route.Cache --version 4.0.1
#r "nuget: redb.Route.Cache, 4.0.1"
#:package redb.Route.Cache@4.0.1
#addin nuget:?package=redb.Route.Cache&version=4.0.1
#tool nuget:?package=redb.Route.Cache&version=4.0.1
redb.Route.Cache
Cache as an EIP (WSO2 Cache mediator / Camel caffeine-cache analog) over the .NET caching
abstractions: IMemoryCache in-process (default, created on demand) or IDistributedCache
(Redis, SQL Server, anything registered in DI).
Caching scope
.Cache("customer-${header.customerId}", TimeSpan.FromMinutes(5))
.Enrich("http://crm/customers/${header.customerId}")
.EndCache()
On a hit the body (and, with .CacheHeaders(), the headers) comes from the cache and the inner
steps are skipped; on a miss they run and the result is stored. Header cache.hit tells which.
Options: .Region("customers"), .SlidingExpiration(...), .CacheHeaders(), .Distributed(),
.KeyFromBody() (SHA-256 of the body instead of an explicit key).
Component
.To("cache:customers?action=get&key=${header.customerId}")
.Filter("header.cache.hit == false")
.Enrich("http://crm/...")
.To("cache:customers?action=put&key=${header.customerId}&ttl=5m")
.EndFilter()
cache:<region>?action=get|put|remove|clear&key=...&ttl=5m&sliding=1m&provider=memory|distributed&cacheHeaders=true.
Durations: 500ms, 30s, 5m, 2h, 1d or hh:mm:ss (a bare number is refused: 5 would be five
days to TimeSpan). get sets cache.hit; clear empties the region. Region and key are joined with a
length-prefixed separator, so region a / key b:c and region a:b / key c are two entries.
What a hit hands back
A miss is computed once per key at a time: concurrent exchanges for the same key wait for the first
one's result instead of each running the inner steps. A Stream body is buffered on the miss (the live
message continues with the bytes) so a hit can replay it; a JsonNode body is copied into and out of the
cache. Text and byte arrays are treated as immutable. Any other object (a POCO, a list) is shared by
every hit by design: do not mutate what a cache scope handed you, or clone it first.
Setup
Nothing for the in-process cache. context.UseCache(o => o.MaxEntries = 10_000) / services.AddRedbRouteCache(o => ...)
register options (and the cache: component in DI). For Distributed, register an IDistributedCache
(services.AddStackExchangeRedisCache(...), AddDistributedMemoryCache(), or
context.AddService(typeof(IDistributedCache), cache)). A POCO body goes through the distributed cache
as JSON and comes back as the same CLR type; clear on a distributed cache removes the keys this
process has written (the abstraction cannot enumerate).
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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 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. |
-
net10.0
- Microsoft.Extensions.Caching.Memory (>= 10.0.3)
- redb.Route (>= 4.0.1)
- redb.Route.Xml (>= 4.0.1)
-
net8.0
- Microsoft.Extensions.Caching.Memory (>= 10.0.3)
- redb.Route (>= 4.0.1)
- redb.Route.Xml (>= 4.0.1)
-
net9.0
- Microsoft.Extensions.Caching.Memory (>= 10.0.3)
- redb.Route (>= 4.0.1)
- redb.Route.Xml (>= 4.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.