Persistence handling in Redis
Redis provides a wide range of options for persisting data. These mechanisms help in deciding what kind of persistence model we need for our data, and that solely depends on the kind of data we want to store in Redis. The four options that we have in Redis are as follows:
Persisting via the RDB option
Persisting via the AOF option
Persisting via combination of AOF and RDB option
Not persisting at all
Let's run a simple program and see the importance of persistence mechanism, because then only we can appreciate the importance of persistence. Follow the steps and see for yourself how lack of persistence can cause data loss:
Start your Redis server.
Open a Redis client command prompt.
Execute the command
SET msg 'temporary value'
.Quickly kill the Redis server manually, either by Kill-9 option in Linux or through close option in Command Prompt in windows.
Restart your Redis server.
Execute the command
get msg
.