⚠ Switch to EXCALIDRAW VIEW in the MORE OPTIONS menu of this document. ⚠ You can decompress Drawing data with the command palette: ‘Decompress current Excalidraw file’. For more info check in plugin settings under ‘Saving’

Excalidraw Data

Text Elements

Cache-aside (Lazy loading)

Cache

Database

App

  1. read cache

  2. cached data

  3. cache miss: read from DB

  4. DB data

  5. update cache

  • simple implementation, app logic handles cache updating
  • more granular control what is cached
  • data can be stale if not updating (cache validation)
  • most popular choice
    • simply and granular control (by application logic)
    • resilience to cache failure => use cache-aside for reads and write-through-invalidation for writes

Read-through (Cache handles data retrieval from DB)

Cache

Database

App

  • simple application code (cache handles data retrieval)
  • ensure data consistency
  • increase complexity (data formatting, …) and more data is loaded on cache
  • data can be stale
  • suitable for CDN?
  1. read cache

  2. cache miss: read from DB

  3. DB data

  4. cache data

Write-around

  • data is written to DB directly (bypass cache) -> write-heavy workload
  • fastest write mechanism
  • data in cache may be stale -> not use

App

Cache

Database

  1. write to DB

  2. read cache

  3. cache data (stale)

  4. cache miss: read DB data

Write-back

  • data is written to cache and sync to DB later -> reduces writes but risks data loss -> write-heavy apps (slight data loss is acceptable), NOT FOR TRANSACTIONS
  • faster write mechanism -> reduces load on DB
  • data may be not consistency

App

Cache

Database

  1. write cache

  2. sync to DB

Write-through

  • data is written to both cache and DB simultaneously (increase write latency) -> write to DB and delete cache
  • data is consistency between cache and DB

App

Cache

Database

  1. write/invalidate cache

  2. write to DB