MENU

Fun & Interesting

I replaced my Redis cache with Postgres... Here's what happened

Milan Jovanović 19,295 lượt xem 4 days ago
Video Not Working? Fix It Now

Get the source code for this video for FREE → https://the-dotnet-weekly.kit.com/postgres-cache
Want to master Clean Architecture? Go here: https://bit.ly/3PupkOJ
Want to unlock Modular Monoliths? Go here: https://bit.ly/3SXlzSt

🚀 Did you know Postgres can be used as a cache?

In this video, I’ll show you how to build a simple yet powerful caching service using just Postgres and SQL—no extra tools required. You'll learn how to:

✅ Store key-value pairs using JSONB
✅ Implement cache invalidation and eviction
✅ Use pg_cron for background cleanup jobs
✅ Leverage unlogged tables for performance
✅ Benchmark Postgres vs Redis using K6
✅ Build a caching abstraction with a clean API

We'll also compare performance with Redis, and I’ll walk you through the benchmarks, architecture, and implementation using .NET Aspire, Dapper, and Docker.

🔗 Get the full source code in the pinned comment below.

Check out my courses:
https://www.milanjovanovic.tech/courses

Read my Blog here:
https://www.milanjovanovic.tech/blog

Join my weekly .NET newsletter:
https://www.milanjovanovic.tech

Chapters
0:00 What is a Caching Service?
2:28 UNLOGGED TABLE syntax
5:23 Caching endpoints SET, GET
9:26 Comparing with Redis
12:26 BONUS: Caching service

Comment