0
0
Redisquery~30 mins

Maxmemory setting in Redis - Mini Project: Build & Apply

Choose your learning style9 modes available
Configuring Redis Maxmemory Setting
📖 Scenario: You are managing a Redis database server that stores cached data for a web application. To prevent Redis from using too much memory and affecting other services on the server, you need to configure the maximum memory Redis can use.
🎯 Goal: Set up a Redis configuration to limit the maximum memory usage to 100 megabytes and verify the setting.
📋 What You'll Learn
Create a Redis configuration file with the maxmemory setting set to 100mb
Add a maxmemory-policy setting to specify how Redis should behave when maxmemory is reached
Use the Redis CLI to check the current maxmemory setting
Confirm the maxmemory-policy is correctly set in the configuration
💡 Why This Matters
🌍 Real World
Limiting Redis memory usage prevents it from consuming all server RAM, ensuring other applications run smoothly.
💼 Career
Configuring Redis memory settings is a common task for database administrators and backend developers managing caching layers.
Progress0 / 4 steps
1
Create Redis configuration file with maxmemory
Create a Redis configuration file named redis.conf and add the line maxmemory 100mb to set the maximum memory to 100 megabytes.
Redis
Need a hint?

The configuration file is a plain text file. Just add the line maxmemory 100mb.

2
Add maxmemory-policy to configuration
In the same redis.conf file, add the line maxmemory-policy allkeys-lru to specify that Redis should remove the least recently used keys when maxmemory is reached.
Redis
Need a hint?

The maxmemory-policy controls eviction behavior. Use allkeys-lru to evict least recently used keys from all keys.

3
Check maxmemory setting with Redis CLI
Use the Redis CLI command CONFIG GET maxmemory to check the current maxmemory setting on the running Redis server.
Redis
Need a hint?

Run redis-cli CONFIG GET maxmemory in your terminal connected to Redis.

4
Verify maxmemory-policy setting with Redis CLI
Use the Redis CLI command CONFIG GET maxmemory-policy to verify that the maxmemory-policy is set to allkeys-lru.
Redis
Need a hint?

Run redis-cli CONFIG GET maxmemory-policy to confirm the eviction policy.