A developer is implementing the Cache-Aside pattern in an Azure App Service web application that retrieves user profile information from an Azure SQL Database. The application uses Azure Cache for Redis to improve read latency. You need to sequence the actions the application must perform when a user profile is requested and a cache miss occurs. Which sequence of actions should the application execute? Move all actions to the answer area and arrange them in the correct order.
- 1Request the user profile from the Azure Cache for Redis instance using the profile key.
- 2Detect a null response from the cache check indicating a cache miss.
- 3Query the primary Azure SQL Database to retrieve the user profile.
- 4Store the retrieved user profile in the cache with a specified expiration time (TTL).
- 5Return the user profile data to the requesting client.
Answer
The application must first request the user profile from the Azure Cache for Redis instance. Upon detecting a null response (cache miss), it queries the primary Azure SQL Database, stores the retrieved user profile back into the cache with a defined Time-To-Live (TTL), and finally returns the data to the client.
The correct sequence begins with checking the cache to see if the requested user profile data is already available. If a cache miss occurs, indicated by a null response, the application must query the authoritative Azure SQL Database. Once the database returns the profile, the application writes that data back to the cache with an appropriate TTL so that future reads will hit the cache. Finally, the user profile is returned to the client.
Step-by-Step Solution
Key Concept
Cache-Aside pattern execution flow for read operations under a cache miss scenario