Soru

Zorluk: ZorImplement Azure Cache for Redis Configuration and Data Patterns

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).

  1. When data is updated in the database, invalidate the corresponding cache key rather than updating the key with the new value.Cevap
  2. 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
  3. C
    Update the cache key directly with the new value immediately after updating the database to ensure maximum read performance.
  4. D
    Configure 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

1
Analyze concurrency safety in the Cache-Aside pattern.
Identify that concurrent writes to the database and direct cache updates can arrive out-of-order, leading to stale data.
Invalidating the cache key is the safest mechanism to ensure data consistency because the next read will pull the single source of truth from the database.
2
Evaluate memory management strategies under load.
Determine that applying a Time-to-Live (TTL) allows Redis to automatically clean up keys that are no longer active.
TTL configuration naturally mitigates memory pressure by deleting stale entries without relying on aggressive global eviction policies.
3
Examine the behavior of the noeviction policy.
Recall that when memory limit is hit under noeviction, any commands that attempt to allocate more memory will return an error.
This shows that the noeviction policy degrades application write capability rather than keeping it unblocked.

Anahtar Kavram

Cache-Aside data pattern consistency and memory management using TTL.
Bu soruyu puanla