A developer is designing a distributed caching system using Azure Cache for Redis to store product catalog data for a highly concurrent e-commerce platform. The system must implement the Cache-Aside pattern, prevent race conditions during concurrent database updates, and prevent memory exhaustion under high load. Which two practices should the developer implement? (Select two).
- When data is updated in the database, invalidate the corresponding cache key rather than updating the key with the new value.Cevap
- Apply a Time-to-Live (TTL) value when writing items to the cache to ensure that unused product details are eventually purged from memory.Cevap
- CUpdate the cache key directly with the new value immediately after updating the database to ensure maximum read performance.
- DConfigure the cache to use the noeviction policy to ensure that active client write operations are never blocked when the cache is full.
Cevap
The developer should invalidate the corresponding cache key rather than updating it directly when the database changes, and apply a Time-to-Live (TTL) value when writing items to the cache to prevent memory exhaustion.
The correct practices are to invalidate the cache key when updating the database and to configure a Time-to-Live (TTL) for cached items. Invalidating the key prevents race conditions where out-of-order writes leave stale data in the cache. Setting a TTL ensures that old or unused data is purged from memory, keeping the cache clean and preventing memory exhaustion.
Adım Adım Çözüm
Anahtar Kavram
Cache-Aside data pattern consistency and memory management using TTL.