I'm experimenting with Redis and digging into the persistence mechanisms.
If I turn on appendonly (appendonly yes) and turn off RDB (save "") in redis.conf file.
Then I start a new database
And set two keys:
SET firstKey "I'm first one"
SET secondKey "I'm second one"
I end up with an appendonly file without any headers, only commands:
raphaeldelio@Raphaels-MacBook-Pro data % cat appendonly.aof
*2
$6
SELECT
$1
0
*3
$3
SET
$8
firstKey
$14
I'm number one
*3
$3
SET
$9
secondKey
$14
I'm number two
Then, if overwrite the first key with:
SET firstKey "I'm still number one"
And then run BGREWRITEAOF
, the file is rewritten and a header similar to the header of the dump.rdb file is added to it:
raphaeldelio@Raphaels-MacBook-Pro data % cat appendonly.aof
REDIS0009? redis-ver6.2.7?
redis-bits?@?ctimežk?bused-mem˜??
aof-preamble???????֭h
????mʗ????~??ױ??firstKeyI'm still number one secondKeyI'm number two??????֭h
????mʗ??????!4d?%
However, I was expecting the file to be rewritten as command logs again.
Therefore I have two questions:
You are referring to an AOF file with an RDB preamble. See also here.