Write-through keeps the cache and database consistent by writing to both synchronously, which makes writes as slow as the database. Write-behind takes the opposite bet: write to the cache immediately, acknowledge right away, and persist to the database asynchronously a moment later. Writes become fast because they only touch memory. The catch is that you've introduced a window where committed writes exist only in Redis, so a crash can lose them. This is the highest-performance and highest-risk caching pattern, and knowing exactly what you're trading is essential before using it.
This is part 11 of the Redis Masterclass, following
About the author
Aman Kumar Singh is a Team Lead & Senior Software Engineer based in Noida, India, writing about full-stack engineering, system design, and production SaaS with TypeScript, Next.js, NestJS, PostgreSQL, and Redis.
- Portfolio:
- LinkedIn: amansingh1597
SOCIAL SHARE CARD GENERATOR