Soru

Zorluk: ZorImplement Azure Cache for Redis Configuration and Data Patterns

An enterprise API uses an Azure Cache for Redis instance to store two distinct categories of data: user session tokens that are assigned a sliding expiration Time to Live (TTL) of 30 minutes, and global application configuration settings that are stored without any TTL. Due to a sudden spike in application usage, the cache memory consumption is approaching its limit. You need to configure a policy that automatically evicts the least recently used session keys under memory pressure, while guaranteeing that all global configuration settings remain in the cache. Which maxmemory-policy configuration should you apply?

  1. volatile-lruCevap
  2. B
    allkeys-lru
  3. C
    volatile-ttl
  4. D
    noeviction

Cevap

volatile-lru
The policy volatile-lru directs Redis to evict keys using the Least Recently Used (LRU) algorithm, but restricts the candidate keys only to those that have an expiration (TTL) set. Because the global configuration settings do not have a TTL, they are excluded from the eviction pool and will remain in the cache, while the session tokens (which do have a TTL) are successfully evicted based on how recently they were used.

Adım Adım Çözüm

1
Analyze the requirements for the cached datasets.
Identify that the session tokens have a TTL (volatile keys) and must be evicted based on least-recently-used (LRU) algorithm, while the configuration settings have no TTL (non-volatile keys) and must not be evicted.
This establishes the key differentiation between volatile keys (with TTL) and non-volatile keys (without TTL).
2
Evaluate the behavior of the candidate maxmemory-policies.
Understand that 'allkeys-lru' scans all keys for eviction, risking configuration loss. 'volatile-lru' only targets keys with an active TTL using LRU, safeguarding configuration. 'volatile-ttl' targets keys with TTL based on shortest remaining lifespan, not LRU. 'noeviction' blocks writes entirely.
Matching the requirements to the functional definition of each Redis eviction policy is necessary to find the compliant configuration.
3
Select the policy that restricts eviction to volatile keys using the LRU algorithm.
Choose 'volatile-lru' as the configuration policy.
This policy ensures that only keys with a TTL are evaluated for eviction using the LRU criteria, protecting the TTL-less configuration data from being deleted.

Anahtar Kavram

Azure Cache for Redis maxmemory-policy eviction behaviors and volatile key scoping
Bu soruyu puanla