TGViewer
TechLead Bits TechLead Bits @techleadbits · 517 subscribers
Post #16 210
Caching CheatSheet

In the past weeks, there have been two big articles discussing caching strategies:
- Mastering Caching in Distributed Applications
- 9 Caching Strategies for System Design Interviews

So it's a good time to review the patterns we use.

Let’s start with the definition of what caching is. I really like the following one:
Caching is the action of storing data in a temporary medium where the data is either cheaper, faster, or more optimal to retrieve rather than retrieving it from its original storage


Caches can be local or distributed.

5 implementation strategies:
✔️Cache-Aside (Lazy-Loading): The app controls reading and writing to the cache. If data's in the cache, it's used; if not, it's fetched from storage and added to the cache.
✔️Write-Through. Both the cache and the database get updated together within the same transaction when you write data. Reading happens only from the cache.
✔️Write-Around. Data is written directly to storage. Usually, it's combined with Cache-Aside for reading.
✔️Write-behind (write-back). Data is first written to the cache and then sent to the datastore asynchronously. The cache product usually handles syncing with the datastore.
✔️Read-Through. The cache is the main place to get data from. If it's not there, it's fetched from storage. Unlike Cache-Aside, the cache product, not the app, decides when and how to fetch data.

Cache invalidation can be performed time-based or event-based.

Cache-eviction strategies:
- Least Recently Used (LRU)
- First In First Out (FIFO)
- Least Frequently Used (LFU)
- Time To Live (TTL)
- Random Replacement

Promising paths for further development in that field:
- AI and Machine Learning-Driven Caching. It can enhance caching mechanisms by predicting data usage patterns and preemptively caching data based on the needs.
- In-Memory Data Grids. They not only cache data but also provide a range of data processing capabilities, real-time analytics, and decision-making directly within the cache layer.

#architecture #patterns
Medium Mastering Caching in Distributed Applications If I had a dollar for every time that I came across a bug with an implementation of caching in a software system… I would probably have…
  • 👍 3
More from @techleadbits
  1. Oct 7, 2026AI & Repository Strategy For many years, there has been an ongoing debate between monorepo…
  2. Oct 1, 2026Tracer Bullets Continuing the topic from the previous post, let's talk in more detail abou…
  3. Sep 28, 2026Why Software Factories Fail "Read the Code!" is one of the key ideas from Dex Horthy's tal…
  4. Sep 21, 2026Illustrations from The Culture Map showing how different cultures compare on the scales. #…
  5. Sep 21, 2026The Culture Map Have you ever worked in international distributed teams? Or collaborated w…
  6. Sep 10, 2026Loop Engineering from First Principles Continuing the topic of Loop Engineering, I'd like…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →