RedisCacheDemo
.NET 9 demo of Redis caching patterns — distributed cache for primitives, complex objects and files, plus a Redis Streams worker with retry and DLQ.
README Snapshot
Redis Cache Demo
A small demo project showing Redis integration and caching techniques in a .NET 9 application. Alongside using Redis as a distributed cache, it demonstrates several caching techniques such as primitive types, complex types, and file caching. The project exists to showcase Redis integration and caching strategies, and to serve as a reference for future work.
Project Structure
RedisCacheService: The service that talks to Redis. It can:
- Cache primitive types (for example, strings).
- Cache complex objects (for example, C# objects).
- Cache files (for example, byte arrays).
RedisStreamWorker: A background service that processes data using a Redis stream. It consumes entries and retries on failure.
Requirements
- Redis: Redis must be installed on your machine, or reachable through a connection string.
- .NET 9 SDK.
Setup
1. Clone the repository
git clone https://github.com/voyvodka/RedisCacheDemo.git
cd RedisCacheDemo
2. Restore dependencies
Run the following command to restore the project's dependencies.
dotnet restore
3. Start Redis
To run Redis with Docker:
docker run --name redis -p 6379:6379 -d redis
Alternatively, you can use a cloud-hosted Redis instance and update the connection string in appsettings.json.
4. Run the application
Use the following command to run the application:
dotnet run
This starts the API server on http://localhost:5259 (or whichever other port is configured).
What the Project Does
RedisCacheService
RedisCacheService stores, retrieves, and deletes data by talking to Redis. It supports caching both simple and complex data types.
RedisStreamWorker
RedisStreamWorker is a background processor that reads and handles data using Redis Streams.
It uses a retry mechanism and a dead letter queue (DLQ) for errors that can occur while consuming entries.
License
This project is licensed under the MIT License. See the LICENSE file for more information.
Changelog
This repository doesn't maintain a dedicated CHANGELOG file. Released notes — when they exist — are listed in the Releases section below.
For an unfiltered view of every change, the commit history on the main branch is the source of truth.
Releases
No tagged releases yet. The current state of the project lives on the main branch, last pushed .