Write Around

Similar to With through (with validation)

sequenceDiagram
    participant App as Application
    participant Cache as Cache
    participant DB as Database (Master)

    Note over App, DB: Write Phase (Bypassing Cache)
    App->>DB: 1. Write Data directly
    DB-->>App: 2. Confirm Success
    Note right of Cache: Cache is NOT updated or deleted

    Note over App, DB: Later: Read Phase
    App->>Cache: 3. Read Request
    Cache-->>App: 4. Cache Miss (Data not there)
    App->>DB: 5. Fetch from DB
    DB-->>App: 6. Return data
    App->>Cache: 7. Store data in Cache for next time

The only different here is that write around will not delete/update cache

Pros:

  • Fast write (ignore cache)
  • Avoid cache pollution (too many keys in cache)
    Cons:
  • Data stale. Consider doing a TTL on data.