Home > Database > Redis > Where is redis data stored?

Where is redis data stored?

anonymity
Release: 2019-06-05 16:43:15
Original
13925 people have browsed it

Redis saves data in memory, but it also writes data to the hard disk regularly.

Where is redis data stored?

Redis has two ways to save data:

Snapshot mode (Snapshot)

It supports two Snapshot mode:

Scheduled snapshot, which saves the data in the memory to the disk at a certain time.

Quantitative snapshot, that is, saving the data to disk after the data changes a certain number of times.

You can also combine these two methods, such as changing 1000 times and saving the data more than 60 seconds from the last save time.

Write mode (Append Only File)

In this mode, Redis will save all commands that modify data (such as Update, Set), etc. into an append-only file. ASAP file, when Redis restarts, it will re-execute the commands in this file.

Where is the data saved?

The data is saved in a data file. The specific file name depends on the Redis configuration file, that is, Redis.conf

config get dbfilename (return dump.rdb)

You can use config set dbfilename new (modify the file you want to save the data in)

How to export the data?

When Redis writes data, it first writes it to a temp file, and then renames the temp file to a predefined file, so even if Redis is running, you can directly copy this file with the cp command.

cp /usr/loca/redis/demo.rdb  /home/greenerycn/db/demo.rdb
Copy after login

The above is the detailed content of Where is redis data stored?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template