Skip to content

Personal / open-source project

Redis Cache Decorator

A Redis cache-aside layer added to the repository tier with the Decorator pattern.

01 · Goal

Add caching without scattering it through business code or breaking the existing repository contract.

02 · Structure

Cached repository classes implement the same interface: read from Redis first, otherwise load from the database and write to the cache with an expiry. .NET 8 with StackExchange.Redis and System.Text.Json.

03 · Highlights

  • A generic cached repository base
  • Key naming and expiry

04 · Takeaway

A small, focused example of isolating caching as a cross-cutting concern.