0
0
Redisquery~30 mins

Why persistence matters in Redis - See It in Action

Choose your learning style9 modes available
Why Persistence Matters in Redis
📖 Scenario: You are managing a small online store that uses Redis to store product stock levels. You want to make sure that if the server restarts, the stock data is not lost.
🎯 Goal: Build a Redis setup that stores product stock levels and enables persistence so data is saved to disk and can be recovered after a restart.
📋 What You'll Learn
Create a Redis hash called stock with exact product keys and stock values
Set Redis configuration to enable RDB snapshot persistence
Add a command to save the current database state to disk
Verify the persistence configuration is set correctly
💡 Why This Matters
🌍 Real World
Persistence in Redis ensures that important data like stock levels are not lost if the server restarts or crashes, which is critical for online stores and real-time applications.
💼 Career
Understanding Redis persistence is essential for backend developers and system administrators to maintain data reliability and availability in production environments.
Progress0 / 4 steps
1
Create the initial stock data
Create a Redis hash called stock with these exact entries: "apple" with value 50, "banana" with value 100, and "orange" with value 75.
Redis
Need a hint?

Use the HSET command to set multiple fields in the stock hash at once.

2
Enable RDB snapshot persistence
Set the Redis configuration to enable RDB snapshot persistence by configuring save to trigger every 60 seconds if at least 1 key changed. Use the command CONFIG SET save "60 1".
Redis
Need a hint?

Use CONFIG SET save "60 1" to save the DB every 60 seconds if at least 1 key changed.

3
Save the current database state to disk
Run the Redis command SAVE to immediately save the current database state to disk.
Redis
Need a hint?

Use the SAVE command to force Redis to write the DB to disk right now.

4
Verify persistence configuration
Use the Redis command CONFIG GET save to verify that the persistence setting is correctly set to "60 1".
Redis
Need a hint?

Use CONFIG GET save to check the current snapshot save settings.