Problem
When NATS is unavailable, reads and writes throw (src/NatsDistributedCache/NatsCache.cs — GetAndRefreshAsync rethrows; the lazy KV-store initializer rethrows on failure). For direct IDistributedCache consumers, a transient NATS blip can cascade into an application outage.
Investigation
HybridCache tends to handle L2 (distributed) failures gracefully, so under HybridCache this is partially absorbed. This option primarily protects direct IDistributedCache consumers and makes the failure behavior explicit and configurable.
Proposal
Add NatsCacheOptions.FailureMode (e.g. Throw (default) | FailOpen):
FailOpen on read → log + return a cache miss.
FailOpen on write → log + swallow.
Throw keeps the current behavior (default, non-breaking).
Acceptance criteria
- With
FailOpen, a simulated NATS outage yields cache misses + logs instead of exceptions.
- Default (
Throw) behavior is unchanged.
Problem
When NATS is unavailable, reads and writes throw (
src/NatsDistributedCache/NatsCache.cs—GetAndRefreshAsyncrethrows; the lazy KV-store initializer rethrows on failure). For directIDistributedCacheconsumers, a transient NATS blip can cascade into an application outage.Investigation
HybridCache tends to handle L2 (distributed) failures gracefully, so under HybridCache this is partially absorbed. This option primarily protects direct
IDistributedCacheconsumers and makes the failure behavior explicit and configurable.Proposal
Add
NatsCacheOptions.FailureMode(e.g.Throw(default) |FailOpen):FailOpenon read → log + return a cache miss.FailOpenon write → log + swallow.Throwkeeps the current behavior (default, non-breaking).Acceptance criteria
FailOpen, a simulated NATS outage yields cache misses + logs instead of exceptions.Throw) behavior is unchanged.