AWS Certified Developer – Associate (DVA-C02) — Question 381
A company runs an ecommerce application on AWS. The application stores data in an Amazon Aurora database.
A developer is adding a caching layer to the application. The caching strategy must ensure that the application always uses the most recent value for each data item.
Which caching strategy will meet these requirements?
Answer options
- A. Implement a TTL strategy for every item that is saved in the cache.
- B. Implement a write-through strategy for every item that is created and updated.
- C. Implement a lazy loading strategy for every item that is loaded.
- D. Implement a read-through strategy for every item that is loaded.
Correct answer: B
Explanation
A write-through caching strategy ensures that data is written to both the cache and the backend Amazon Aurora database simultaneously, which guarantees that the cache always contains the most up-to-date values. In contrast, lazy loading and TTL strategies can result in stale data because they only update the cache after a cache miss or when the TTL expires. Similarly, a read-through strategy loads data into the cache only after a read miss occurs, meaning it does not prevent stale data immediately following a database write.