Skip to content

ADR-002: Redis via StackExchange.Redis — Distributed Cache

Date: 2026-02-21 Authors: Jean-Francois Meyers Scope: granit-dotnet (Granit.Caching, Granit.Caching.StackExchangeRedis, Granit.Caching.Hybrid)

The Granit framework provides cache abstractions (Granit.Caching) and requires a distributed cache backend for:

  • Performance: reducing latency for frequent reads (settings, translations, templates, permissions)
  • Scalability: shared cache across Kubernetes instances (sticky sessions impossible in an ISO 27001 context — high availability required)
  • Idempotency: HTTP idempotency key storage
  • SignalR: Redis backplane for real-time notifications

The choice of cache backend determines the implementation of Granit.Caching.StackExchangeRedis and the L1+L2 pattern of Granit.Caching.Hybrid.

Redis via StackExchange.Redis as the distributed cache backend (L2), combined with Microsoft.Extensions.Caching.Hybrid for the L1+L2 pattern.

Option 1: Redis via StackExchange.Redis (selected)

Section titled “Option 1: Redis via StackExchange.Redis (selected)”
  • License: MIT (StackExchange.Redis)
  • Advantage: de facto standard, native IDistributedCache integration, HybridCache support, Pub/Sub for invalidation, SignalR backplane
  • Advantage: simple, lightweight, performant for pure key-value
  • Disadvantage: no Pub/Sub, no advanced data structures, no persistence, no SignalR backplane
  • Advantage: .NET native solution, advanced topologies
  • Disadvantage: commercial license, limited community, no standard HybridCache integration
  • Advantage: Redis protocol compatible, superior performance
  • Disadvantage: recent project (2024), no managed service, stability risk for ISO 27001 production use
CriterionSE.RedisMemcachedNCacheGarnet
Client licenseMITApache-2.0FreemiumMIT
IDistributedCacheNative MSThird-partyThird-partyCompatible
HybridCache .NET 10YesNoNoCompatible
Pub/SubYesNoYesYes
SignalR backplaneYes (MS official)NoNoUntested
Maturity10+ yearsMatureMatureRecent
  • Native integration with Microsoft DI (IDistributedCache, HybridCache)
  • MIT client, stable and very widely adopted
  • Pub/Sub for cache invalidation and SignalR backplane
  • Transparent L1+L2 HybridCache pipeline via Granit.Caching
  • Redis is an additional infrastructure dependency to operate
  • Redis 7.4+ license (SSPL): to monitor if self-hosted
  • Complex object serialization requires a consistent strategy

This decision should be re-evaluated if:

  • Microsoft Garnet reaches production maturity and offers a managed service
  • The Redis license (SSPL) becomes problematic for self-hosted deployment
  • Cache needs evolve toward a pattern incompatible with Redis (e.g. geographically distributed cache)