Home Cache Strategy
Post
Cancel

Cache Strategy

1. Cache Aside

Cache Aside Application update cache data only when cache miss occurs reading from database

When to use

Massive read workload

Pros

  • Have elasticity in error since cache memory is separated even though cache cluster is down
  • Can have different data schema

Cons

  • Synchronization issue Not always sync cache data with database

  • Slow when cache miss occurs

2. Read Through

Database update cache when cache miss

Read Through

When to use

Massive read workload

Pros

  • Always data is synchronized if using with Write-Through

Cons

  • Data schema should follow database entity schema
  • First request data always meets cache miss

3. Write Through

Application write all data in cache first and synchronized with db

Write Through

When to use

All cache data must be synchronized.

Pros

  • Always data is synchronized between cache and DB

Cons

  • All data is in cache even though which is not used.
  • Write operation performance degradation since all write operations must be hit DB

4. Write Behind

Write Behind

When to use

Massive write workload
R/W work load
Read through + Write Behind strategy => Fast R/W and can get synchronized data

Pros

  • Fast write operation
  • Using batch write from cache to DB, can reduce db write operations

Cons

  • Not strong consistency between cache and DB
  • Exists data loss probability when cache error occurs

Redis Gears

You can use Redis Gears when to use Write-Through or Write-Behind strategy.

DAX

You can use DAX when to use Read-Through + Write-Through strategy.

This post is licensed under CC BY 4.0 by the author.

인덱스 컬럼을 어떻게 선택할까?

Database Partitioning

Trending Tags