Skip to content

Latest commit

 

History

History
55 lines (45 loc) · 1.94 KB

File metadata and controls

55 lines (45 loc) · 1.94 KB

Cache-Aside

Motivation

  • Some caching systems don't provide read-through and write-through/write-behind operations.

Solution

Concepts

  • Applications take the responsibility of using the cache to maintain data.
  • The cache does not interact with database directly.

Implementation

Read Operation

  • Check the requested record is held in the cache or not:
    • If the requested record is held in the cache:
      • Return the record directly.
    • If the requested record is not in the cache:
      • Read the record from the database and return it.
      • Store the copy of the record in the cache.

Write Operation

  • Write the record into the database.
  • Invalidate the corresponding record in the cache.

Pros & Cons

Pros

  • Improve performance on read operations generally.

Cons

  • Cost more efforts on development (Applications need to handle both cache and database).
  • Data in the cache can become stale if it is updated in the database.
  • Each cache miss causes a noticeable delay (Data need to load from database to cache through application).

Consideration

Topic Consideration Possible Solution Options

When To Use

  • The cache doesn't provide read-through and write-through/write-behind operations.
  • The application performs more read operations than write operations.

References