0
0
Redisquery~15 mins

Eviction policies overview in Redis - Mini Project: Build & Apply

Choose your learning style9 modes available
Eviction Policies Overview in Redis
📖 Scenario: You are managing a Redis cache for a web application that stores user session data. The cache has limited memory, so you need to understand how Redis handles data eviction when it runs out of space.
🎯 Goal: Learn how to configure and observe different Redis eviction policies to manage memory usage effectively.
📋 What You'll Learn
Create a Redis configuration dictionary with memory limit and eviction policy
Add a variable to hold the maximum memory size in bytes
Write a command to set the eviction policy in Redis configuration
Complete the Redis configuration with the eviction policy and max memory settings
💡 Why This Matters
🌍 Real World
Managing Redis eviction policies helps keep your cache efficient and prevents application errors due to memory exhaustion.
💼 Career
Understanding Redis eviction policies is important for backend developers and system administrators who optimize caching strategies.
Progress0 / 4 steps
1
DATA SETUP: Create Redis configuration dictionary
Create a dictionary called redis_config with these exact entries: 'maxmemory' set to 0 and 'maxmemory-policy' set to 'noeviction'.
Redis
Need a hint?

Use a Python dictionary with keys 'maxmemory' and 'maxmemory-policy'.

2
CONFIGURATION: Add max memory size variable
Create a variable called max_memory_bytes and set it to 104857600 (which is 100 MB).
Redis
Need a hint?

Set max_memory_bytes to 104857600 to represent 100 MB.

3
CORE LOGIC: Update eviction policy in configuration
Update the redis_config dictionary to set 'maxmemory-policy' to 'allkeys-lru'.
Redis
Need a hint?

Change the value of 'maxmemory-policy' key in redis_config to 'allkeys-lru'.

4
COMPLETION: Set maxmemory to max_memory_bytes
Update the redis_config dictionary to set 'maxmemory' to the value of max_memory_bytes.
Redis
Need a hint?

Assign max_memory_bytes to the 'maxmemory' key in redis_config.