Intro to caching design patterns
A brief overview of caching design patterns with Redis
You are about to create a new application, and one of your goals is to create a "blazing fast" end product to meet your demands, contracts, or street cred. You can go with a high-performance language like Rust and achieve top-tier speeds when done right but sometimes that option is not available; your contract demands you use Python, Rust is too hard, or your favourite tech stack is Nodejs based. Achieving high performance will now require designing the application with speed in mind just as it needs security "baked in".
There is no one magic pill to make the software run faster but over time, the community has learned common techniques that work as reliable patterns to solve problems such as application performance. To prevent and resolve performance issues, software devs and architects use caching technologies such as Redis and they do so in different ways depending on the situation.
In this series, we'll look into three popular design patterns used with Redis to improve performance:
The master data-lookup pattern
The cache-aside pattern
The write-through pattern
The write-behind pattern
For demo purposes, we are going to create a simple API for posting and creating comments on posts. The api will use:
Express
Typescript
Postgres with Prisma orm
Redis
Node-cron
The full code can be found here
Features Story
A user will create an account with an email and password
A user can log in with an email and password.
A user can create, update and disable posts after authorization.
A user can create, update and disable comments after authorization.
Thank you for reading this far, I hope you are liking it, and feel free to jump into the next blog in the series.