Intro to caching design patterns

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:

  1. The master data-lookup pattern

  2. The cache-aside pattern

  3. The write-through pattern

  4. 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:

  1. Express

  2. Typescript

  3. Postgres with Prisma orm

  4. Redis

  5. 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.