
Answer-first summary for fast verification
Answer: Implement the write-through caching strategy
## Explanation The correct answer is **B. Implement the write-through caching strategy**. ### Why Write-Through Caching Strategy? 1. **Simultaneous Updates**: Write-through caching ensures that when data is written to the database, it is also immediately written to the cache. This guarantees that the cache always contains the most recent data. 2. **Data Consistency**: The requirement states that "the data in the cache must always match the data in the database." Write-through caching maintains this consistency by updating both storage layers simultaneously. 3. **Real-time Synchronization**: When a customer adds an item to the database, the write-through strategy automatically adds or updates that data in the cache, ensuring immediate consistency. ### Why Not the Other Options? - **A. Lazy Loading (Cache-Aside)**: This strategy only loads data into the cache when it's requested (read operations). It doesn't proactively update the cache on write operations, which could lead to stale data. - **C. Adding TTL Caching Strategy**: Time-To-Live (TTL) is an expiration mechanism, not a write strategy. It helps manage cache freshness but doesn't ensure immediate consistency when data is written to the database. - **D. AWS AppConfig Caching Strategy**: AWS AppConfig is a service for managing application configurations, not a database caching strategy. It's unrelated to maintaining cache-database consistency. ### Key Benefits of Write-Through for This Scenario: - **Strong Consistency**: Cache and database are always synchronized - **Write Performance**: While writes are slower (must update both cache and database), reads are extremely fast - **Data Integrity**: No stale data in cache after writes - **Suitable for Critical Data**: Ideal when data accuracy is paramount, as in this company's requirement This approach perfectly aligns with the company's requirement to have cache data always match database data when customers add items.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
A company hosts a three-tier web application in the AWS Cloud. A Multi-AZ Amazon RDS for MySQL server forms the database layer. Amazon ElastiCache forms the cache layer. The company wants a caching strategy that adds or updates data in the cache when a customer adds an item to the database. The data in the cache must always match the data in the database.
Which solution will meet these requirements?
A
Implement the lazy loading caching strategy
B
Implement the write-through caching strategy
C
Implement the adding TTL caching strategy
D
Implement the AWS AppConfig caching strategy