Cache (Multi-Layer)
/cache Tier 1
Read-through cache with singleflight stampede protection and automatic L1 back-fill on L2 hits. Layers are checked in order: L1 (fast, local) → L2 (shared, e.g. Redis). On miss, the handler runs once and the result is written to all layers.
Signature
action contract.Cache(ttl time.Duration, keyFn func(Req) string, layers ...CacheLayer[Res]) *Builder[Req, Res]