SAA-C03 Question 492
Single answerAn e-commerce company is experiencing high latency when retrieving frequently accessed product data from its relational database. To improve performance, they want to implement a caching strategy. They need the solution to automatically invalidate the cache when data in the database changes. Which solution is the MOST appropriate for this requirement?
- A
Use Amazon ElastiCache with a write-through caching strategy.
- B
Use Amazon ElastiCache with a lazy-loading caching strategy.
- C
Use Amazon ElastiCache with a TTL (Time-to-Live) expiration policy.
- D
Use Amazon ElastiCache with DynamoDB Streams to implement cache invalidation.
Show answer and explanation
Correct answer: D
Explanation
To meet the requirement of automatically invalidating the cache when data in the database changes, the most appropriate solution is to use Amazon ElastiCache with DynamoDB Streams. DynamoDB Streams can capture database changes in real-time, and you can use them to trigger cache invalidation logic, ensuring the cache remains up-to-date with the database. Other options, such as write-through or lazy-loading strategies, do not provide real-time invalidation for changes made directly to the database.
- A. Incorrect.
A write-through caching strategy automatically updates the cache whenever a write is made to the database. However, it does not automatically detect changes made directly to the database by other processes, making it unsuitable for this scenario.
- B. Incorrect.
A lazy-loading strategy fetches data into the cache only when it is requested and not found in the cache. It does not handle automatic cache invalidation when database changes occur.
- C. Incorrect.
Using a TTL (Time-to-Live) expiration policy can help ensure cached data is periodically refreshed, but it does not provide real-time invalidation when the database changes occur.
- D. Correct.
Using Amazon ElastiCache with DynamoDB Streams allows you to listen to changes in the database in real-time and implement automatic cache invalidation, making it the most appropriate solution for this requirement.