#What is redis?
Redis is a high-performance key-value database. The emergence of redis has largely compensated for the shortcomings of key/value storage such as memcached, and can play a very good supplementary role to relational databases in some situations. It provides Java, C/C, C#, PHP, JavaScript, Perl, Object-C, Python, Ruby, Erlang and other clients, which is very convenient to use. (redis tutorial)
How does redis store data?
Redis saves data in memory, but it also writes data to the hard disk regularly.
Redis has two ways to save data:
1. Snapshot mode (Snapshot)
It supports two snapshot modes:
1. Scheduled snapshot, that is, saving the data in the memory to the disk at a certain time.
2. Quantitative snapshot, that is, saving the data to the disk after the data changes a certain number of times.
2. Write mode (Append Only File)
In this mode, Redis will save all commands that modify data (such as Update, Set), etc. into an ASAP file that can only be appended. , 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)
The above is the detailed content of How redis stores data. For more information, please follow other related articles on the PHP Chinese website!