Question

Difficulty: MediumImplement Azure Cache for Redis Configuration and Data Patterns

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.

  1. 1Request the user profile from the Azure Cache for Redis instance using the profile key.
  2. 2Detect a null response from the cache check indicating a cache miss.
  3. 3Query the primary Azure SQL Database to retrieve the user profile.
  4. 4Store the retrieved user profile in the cache with a specified expiration time (TTL).
  5. 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

1
Check the cache using the target key.
A null or empty response is returned, indicating a cache miss.
Checking the cache first prevents unnecessary load on the backend database.
2
Query the primary database.
The requested user profile is retrieved from the database.
The database is the system of record and holds the data when a cache miss occurs.
3
Write the data to the cache.
The cache is populated with the profile data and an associated TTL.
Populating the cache on read-miss is the core mechanism of the Cache-Aside pattern to optimize subsequent requests.
4
Return the user profile data.
The requesting client receives the data.
This completes the lifecycle of the client request.

Key Concept

Cache-Aside pattern execution flow for read operations under a cache miss scenario
Rate this question