AI-200 · 2.3.1 · Develop AI solutions by using Azure data management services
Redis cache-aside
Implement Azure Managed Redis data operations, including caching, expiration, and invalidation
Check Redis first, load and cache on a miss, set a , and invalidate only after the source database has been updated.
Read through the cache

In , the application checks Redis first. On a miss, read the source database, return the value, and cache a copy with a .
value = r.get(key)
if value is None:
value = load_from_database()
r.set(key, value, ex=300)
return value
Invalidate after the source changes
Write the source of truth first, then delete the cached key.
update_database(value)
r.delete(key)
Deleting first creates a race: another request can reload the old database value and put stale data back into Redis before the database update finishes.
Expiration is part of the design
Give cached keys a TTL so forgotten entries disappear. With an that only considers expiring keys, keys without a TTL are protected from that eviction pool.
Keep Redis operations cheap
Keep values reasonably small, use pipelining when several operations can be sent together, and avoid broad key scans such as KEYS. Azure Managed Redis uses TLS and its current endpoint port is 10000.
Key points
- : read Redis first, then fill the cache after a miss
- Expiration: set a when caching values
- Write path: update the source first, then delete the cached key
- : deleting first can reintroduce stale data during a race
- Efficiency: small values, pipelining, and no broad `KEYS` scans
- Connection: Azure Managed Redis uses TLS on port 10000
Click an underlined term for a one-line explanation, or see them all in the glossary .
Exam trap
Assuming the cache cleans itself: with the default volatile-lru policy, keys without a are never evicted and memory only grows.
Sources · 4 Microsoft Learn pages Show ▾
- Cache-Aside pattern (Azure Architecture Center)
- Best practices for memory management (Azure Managed Redis)
- Quickstart: Create a Python app with Azure Managed Redis
- Best practices for development (Azure Managed Redis)
Checked on October 4, 2026. Report a problem
Go deeper on Microsoft Learn
- Cache-Aside pattern (Azure Architecture Center)
- Best practices for memory management (Azure Managed Redis)
- Quickstart: Create a Python app with Azure Managed Redis
- Best practices for development (Azure Managed Redis)
Checked against Microsoft Learn on October 4, 2026. Report a problem with this card