简体   繁体   中英

How does Redis persist data on my local Apache server even after reboot and complete power down?

From how I understand, Redis uses in memory from which I gather my RAM if I am running a local apache development server. I tried powering down my computer and disconnected the power cable as well, but the redis data on my local server development website persisted when I powered back up my computer and tested my test website again. I thought RAM data gets completely wiped when I do a system reboot, how does Redis persist data even after reboot on my local development environment? Thanks! :)

Redis serves data only out of RAM, but it provides two modes of persistence RDB (snapshot persistence) and AOF (changelog persistence). If either mode of persistence is enabled on your Redis server, then your data will persist between reboots.

The config directives you want to check are:

  • appendonly yes
  • save

More information on Redis Persistence here.

Redis has persistence options that saves Redis data in either RDB or AOF format (basically saving the Redis data to a file/log):

  • The RDB persistence performs point-in-time snapshots of your dataset at specified intervals.

  • The AOF persistence logs every write operation received by the server, that will be played again at server startup, reconstructing the original dataset. Commands are logged using the same format as the Redis protocol itself, in an append-only fashion. Redis is able to rewrite the log on background when it gets too big.

  • If you wish, you can disable persistence at all, if you want your data to just exist as long as the server is running.
  • It is possible to combine both AOF and RDB in the same instance. Notice that, in this case, when Redis restarts the AOF file will be used to reconstruct the original dataset since it is guaranteed to be the most complete.

This info was quoted from https://redis.io/topics/persistence , which goes into detail about these options.

You can read more from the Antirez weblog: Redis Persistence Demystified

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM