0
0
Redisquery~5 mins

RDB configuration (save intervals) in Redis

Choose your learning style9 modes available
Introduction

RDB configuration with save intervals helps Redis save data snapshots automatically. This keeps your data safe without slowing down your app.

You want Redis to save data every few minutes or after some changes.
You need to recover data after a crash or restart.
You want to balance between performance and data safety.
You want to control how often Redis writes data to disk.
You want to avoid losing too much data if Redis stops unexpectedly.
Syntax
Redis
save <seconds> <changes>

This command sets Redis to save data if changes keys were made in seconds seconds.

You can have multiple save intervals by repeating the save line with different values.

Examples
Save if at least 1 change happened in 900 seconds (15 minutes).
Redis
save 900 1
Save if at least 10 changes happened in 300 seconds (5 minutes).
Redis
save 300 10
Save if at least 10,000 changes happened in 60 seconds (1 minute).
Redis
save 60 10000
Multiple save intervals for different conditions.
Redis
save 900 1
save 300 10
save 60 10000
Sample Program

This configuration tells Redis to save the database snapshot if any of these conditions happen: 1 change in 15 minutes, 10 changes in 5 minutes, or 10,000 changes in 1 minute.

Redis
# Example redis.conf snippet
save 900 1
save 300 10
save 60 10000
OutputSuccess
Important Notes

Setting save intervals too often can slow Redis because it writes to disk more.

Setting save intervals too far apart risks losing more data if Redis crashes.

You can disable saving by commenting out all save lines.

Summary

RDB save intervals control when Redis saves data snapshots automatically.

You set intervals by specifying time and number of changes.

Multiple intervals can be set for flexible saving rules.