Logo

Stores the data and programs that are frequently used by the CPU. So any time some data is required it is first checked in the cache memory.

Performance of Cache Use:

Hit ratio = hit/(hit + miss) = no. of hits/ total access.

Types

TypeDesc / Examples
1. In MemoryRedis & Memcached - Uses RAM not Disk
2. DistributedRedis Cluster & AWS Elastic Cache - Distributed In Memory Caches
3. Client SideCookies , local storage - Usually for scripts, states, etc
4. DB CachesDatabase Indexes help speed up reads
5. CDNsCache static files (based on proximity) - ref

Cache Strategies

Usually for In Memory Caches

1. Read Through (Hit / Miss)

Pasted image 20241030132313.png

  • App reads from Cache (return on Hit)
  • On Miss:
    • Cache requests from DB
    • Store in Cache & serves to App
  • Good for: Read Heavy Caches (using TTL to store LRU Cache)

2. Cache Aside (Lazy Loading)

Pasted image 20241030132612.png

  • Similar to above
  • Difference: App handles control to write on cache
  • Good for: High Read to Write Ratio i.e; read >> write

3. Write Through (Logging ACK)

Pasted image 20241030132909.png

  • Every write operation is executed on both the cache and the DB
  • Consistency improved

© 2025 All rights reservedBuilt with DataHub Cloud

Built with LogoDataHub Cloud