r/SpringBoot • • Oct 30 '26

Discussion Write-back caching in Redis using Spring Boot?

I was wondering if how would y'all write a write-back (or write-behind) caching in Spring Boot, particularly using redis. I couldn't quite look for a more decent implementation especially for production. Would you mind helping a spring boot newbie out? Thanks yall.

2 Upvotes

5 comments sorted by

View all comments

4

u/Torutofu_Raeva Oct 30 '26

spring's cache abstraction only does read-through/write-through, so for write-behind i'd write to redis and push the change onto a redis stream, then a consumer batches it into the db. just accept you can lose writes if redis dies before the flush

2

u/TaySwen Oct 30 '26

This. I was doing a poc and had to use Redis Stream and batches to the Db and the trade-off is real