Exploring AOF
In the previous recipe, we learned how to set up AOF persistence in Redis. In this recipe, we are going to take a look at the content of the AOF file and explain the AOF rewrite process.
Getting ready…
You need to finish the installation of the Redis Server, as we described in the Downloading and installing Redis recipe in Chapter 1, Getting Started with Redis.
For the purpose of demonstration, we need to disable AOF and flush all the data with the FLUSHALL
command first.
How to do it...
The steps for exploring AOF are as follows:
- Enable AOF persistence:
127.0.0.1:6379> CONFIG SET appendonly yes
OK
- Since there is no data in Redis, we should have an empty AOF file:
$ ls -l
-rw-rw---- 1 redis redis 0 Oct 23 20:47 appendonly.aof
- Run the following commands in
redis-cli
:
127.0.0.1:6379> SET k1 v1
OK
127.0.0.1:6379> INCR counter
(integer) 1
127.0.0.1:16379> INCR counter
(integer) 2
127.0.0.1:6379> SET k2 v2
OK
127.0.0.1:6379> DEL k1
(integer) 1
127.0.0.1:6379...