Data

Cache-Aside

Description

The application code effectively maintains the cache. It attempts to read from cache; if miss, it reads from DB and writes to cache.

Where to use

  • General caching strategy.
  • \n
  • Read-heavy data.

Real World Example

App checks Redis for 'user:123'. If missing, fetches from MySQL, saves to Redis, and returns to user.

Code Example

class Cache-Aside:\n    def __init__(self):\n        pass\n\n    def execute(self):\n        print('Executing Cache-Aside')