Skip to content

The lifecycle of a cached value

A read hits the cache, a write invalidates it, the next read repopulates it from the source.

sequenceDiagram
  participant U as User
  participant C as Cache
  participant D as Database
  U->>C: GET /profile
  C-->>U: stale
  Note over U: User updates profile
  U->>D: PUT /profile
  D->>C: invalidate /profile
  U->>C: GET /profile
  C->>D: fetch
  D-->>C: fresh
  C-->>U: fresh