Cache

CleanShot 2024-09-25 at 17.14.51.png

Types of cache

Application caching

In-memory caches such as Memcached and Redis are key-value stores between your application and your data storage. Since the data is held in RAM, it is much faster than typical databases where data is stored on disk. RAM is more limited than disk, so cache invalidation algorithms such as least recently used (LRU) can help invalidate 'cold' entries and keep 'hot' data in RAM.

High performance

Redis

Redis has the following additional features:

There are multiple levels you can cache that fall into two general categories: database queries and objects:

Generally, you should try to avoid file-based caching, as it makes cloning and auto-scaling more difficult.

When to update cache

Cache-aside (Memcached)

Disadvantages

Write through

Disadvantages

Write behind (write-back)

Disadvantage(s): write-behind

Refresh-ahead

Cache Disadvantages

Memcached vs Redis