Question

Difficulty: EasyImplement Azure Cache for Redis Configuration and Data Patterns

You configure an Azure Cache for Redis instance for an application. You want to ensure that no keys are ever automatically deleted when the cache reaches its memory limit, and that any write operations fail with an error instead.

Which two options describe the correct configuration parameter or behavior for this scenario?

  1. The maxmemory-policy configuration setting must be set to noeviction.Answer
  2. Write commands (such as SET or HSET) will return an error when the memory limit is reached.Answer
  3. C
    The maxmemory-policy configuration setting must be set to volatile-lru to allow only keys without an expiration time to be evicted.
  4. D
    The cache will automatically start evicting the least recently used keys across all keys in the cache regardless of expiration.

Answer

To prevent any key eviction under memory pressure and fail writes with an error, the maxmemory-policy must be set to noeviction, which causes write commands to return an out-of-memory error when the cache is full.
To prevent any data from being evicted from the cache under memory pressure, the maxmemory-policy must be set to noeviction. Under this policy, when the cache reaches its memory limit, any commands that attempt to write or add new data will fail and return an out-of-memory error to the application, while read-only requests continue to be served.

Step-by-Step Solution

1
Identify the memory behavior requirement.
The application requires that no keys are ever automatically deleted (evicted) under memory pressure and that write operations fail with an error when the cache is full.
This requirement determines the eviction policy needed for the Redis instance.
2
Select the appropriate maxmemory-policy setting.
Setting maxmemory-policy to noeviction ensures that Redis does not evict any data when full.
The noeviction policy is the only Redis policy that guarantees no keys will be evicted under memory pressure.
3
Determine the resulting application behavior under memory pressure.
Write commands will fail and return errors to the client application, while read-only commands continue to function normally.
This is the default and expected behavior of the noeviction policy when the cache memory limit is reached.

Key Concept

Azure Cache for Redis Eviction Policies
Rate this question