0

I am new to using Redis and I am playing around a little bit with it. I have noticed that after a little time, let's say 10 minutes all the keys that I inserted just go away. I just did the default installation showed in the documentation. I didn't configure anything with a redis.config. Is there any configuration that I need to do so my data can persist?

Environment

Redis Server

Redis server v=6.2.6 sha=00000000:0 malloc=jemalloc-5.1.0 bits=64 build=557672d61c1e18ba

Redis-cli

redis-cli 6.2.6

Ubuntu 18.08 VM. I have also been using redisInsight to insert the keys.

Erick Villatoro
  • 170
  • 1
  • 9

1 Answers1

0

there are two mechanisms for persisting the data to disk:

  1. snapshotting
  2. append-only file (aof)

if you want to use snapshotting, you need to add the following settings in redis.conf file

  • dir ./path_for_saving_snapshot
  • dbfilename "name_of _snapshot.rdb"
  • save 60 1000

with this configuration, redis will dump the data to disk every 60 seconds if at least 1,000 keys changed in that period.

if you want to use aof, you need to add the following settings in redis.conf file

  • appendonly yes
  • appendfilename "your_aof_file.aof"
  • appendfsync everysecond

everysecond is the default FYSNC policy. you have also other options.

You can configure your Redis instance to use either of the two mechanisms or a combination of both.

Shoobi
  • 88
  • 1
  • 10
  • Yeah, I get the fact that the data should be written into the disk. The issue that I am getting is that every certain time the data is flushing. I am just getting 4 backups strings and all my keys are gone. – Erick Villatoro Apr 18 '22 at 00:31