0
0
Redisquery~5 mins

AOF rewrite process in Redis

Choose your learning style9 modes available
Introduction
The AOF rewrite process helps keep the Redis database file small and fast by cleaning up old commands and saving only the current data.
When the AOF file becomes very large and slow to load.
To reduce disk space used by Redis data.
To improve Redis startup time by having a smaller AOF file.
When you want to keep a safe backup of your current database state.
To maintain Redis performance during long running operations.
Syntax
Redis
BGREWRITEAOF
This command runs the AOF rewrite in the background without stopping Redis.
It creates a new, smaller AOF file with only the current data.
Examples
Starts the AOF rewrite process in the background.
Redis
BGREWRITEAOF
Enables AOF persistence and then triggers the rewrite process.
Redis
CONFIG SET appendonly yes
BGREWRITEAOF
Sample Program
This sequence enables AOF, starts the rewrite, and shows persistence info.
Redis
CONFIG SET appendonly yes
BGREWRITEAOF
INFO persistence
OutputSuccess
Important Notes
The BGREWRITEAOF command does not block Redis, so your database stays available.
If a rewrite is already running, issuing BGREWRITEAOF again will schedule another rewrite after the current one.
AOF rewrite helps reduce file size by removing redundant commands.
Summary
AOF rewrite cleans and compacts the Append Only File to save space.
Use BGREWRITEAOF to start the rewrite without stopping Redis.
This process improves Redis startup speed and disk usage.