Redis › Caching Patterns
How do you decide which caching pattern, cache aside, write through, or write behind, is right for a specific application feature?
IntermediateAnswer
You consider how tolerant the feature is to slightly stale data, how critical it is that a write is never lost, and how much read versus write traffic the feature experiences, generally choosing cache aside for read heavy data that can tolerate small delays before being cached, write through when consistency matters most, and write behind when write speed is the top priority and some risk of data loss is acceptable.
-- Read heavy, tolerant of staleness: cache aside
-- Consistency critical: write through
-- Write speed critical, some risk acceptable: write behindReal-world example A team building a product catalog chooses cache aside since catalog data changes infrequently and can tolerate being slightly out of date, while choosing write through for account balance data where consistency is critical.