Which Pattern to Use? 00:00:01 Start with the decision the stale value could change A storefront wants fast browsing, prompt profile updates and correct withdrawals. Before selecting a pattern, ask which operation needs the newest authoritative state and what a stale answer would cost. Reads, writes, or seeing the latest value. Pick the one that hurts. Rarely, over hours or days: cache-aside. Sometimes, every few minutes: write-through if people must see it at once. Then ask if the data is critical. Counts and logs: write-back. Anything you cannot lose: write-through. Yes: write-back. No: a cache in front will not speed up safe writes. Keep the database in the path and fix the write itself. Yes: write-through. No: cache-aside with a TTL. If the value must be exact for a decision, skip the cache. A page description can tolerate a different contract from granting access or spending money. Specify the read and write promises feature by feature. 00:01:07 Put the same edit through three write paths Make one update and one immediate read with the illustrated latency costs. Track which component acknowledges and which component still needs work after the user receives a response. Write the database, delete the key. 10 plus 1 equals 11 ms. Write the database, set the key. 10 plus 1 equals 11 ms. Set the key and answer. 1 ms. The database follows. Cache-aside: a miss of 12 ms. The other two: a hit of 1 ms. A low measured write latency may simply move persistence into a background queue. Include work and risk after acknowledgement when comparing candidate patterns. 00:01:53 Fail a component at the least convenient instant Keep the workload constant and stop a component during each write policy. Compare whether the user sees delay, an old copy or loss of an acknowledged update. Reads fall back to the database. Slower, correct. If a save needs both, saves now fail. Write the database, queue a delete for the key, answer. Reads fall back. Everything since the last flush is gone, unless a log or a replica has it. Choose a recovery plan, not just a fast path. Distinguish rebuildable cache data from writes whose only new copy was held by the cache. 00:02:31 Combine policies inside one checkout product Descriptions, profile preferences, view counts and stock claims have different access patterns. Draw the transaction boundary for each rather than requiring the entire shop to use one caching recipe. Read very often, changed rarely. Cache-aside with a TTL. Read right after saving. Write-through. Changes all the time, a few lost views do not matter. Write-back. Decided in a database transaction. The cache is not asked. Mixed policies need clear ownership and compatible keys. Avoid reading one feature's convenient projection as if it were another feature's authority. 00:03:10 A displayed balance is not permission to withdraw A bank may display a previously observed balance with an appropriate freshness policy. Now switch from a read-only display to authorizing a debit. Which component must coordinate competing transactions? The home screen may show a balance that is a few seconds old, with a time next to it. The person expects the new number, so the save updates or deletes the copy. Is there enough money? Ask the database, inside the transaction. Never the cache. Perform the spending decision at the authoritative transactional boundary. The shop can choose a cache from the outcome it must protect, instead of treating faster reads as a universal answer.