Write-through caching updates the primary data store and the in-memory cache when application data changes. Later reads go to the cache, keeping frequently requested data off the primary store. The cache sits between the application and its database. section 11.0
A basic application flow is:
- Write an updated value to the data store and the cache. section 11.0
- For a later read, request the value from the cache and return it to the client. section 11.0
Updating both places during the write helps keep cached values current. A variation fills the cache asynchronously through a background job, AWS Lambda function, or the application; that variation needs care because the cache update may not have finished when a read arrives. Unlike relying on a time-to-live (TTL) to expire old entries, this approach refreshes cached data when it changes. section 11.0 section 11.7
Leaderboard capacity
Suppose each team leaderboard takes 4 KB and the cache has 1 GB (1,048,576 KB) available. It can hold 262,144 such leaderboards. More teams than that create a capacity problem: a full cache may evict entries or stop accepting new data. Check whether the data you intend to write through will fit. section 11.0
Compare where lazy-loading and write-through strategies place the cache update in the application's data flow. section 11.0
Test application performance with and without caching, and compare approaches before choosing one. Keeping data current is useful, but memory capacity remains a limit; decide how the application should handle entries that cannot remain in the cache. section 11.0


