Home >Database >Redis >Where does redis store data

Where does redis store data

(*-*)浩
(*-*)浩Original
2019-11-29 10:55:585366browse

Where does redis store data

Redis is a key-value storage system. Similar to Memcached, it supports relatively more stored value types, including string (string), list (linked list), set (set), zset (sorted set - ordered set) and hash (hash type). (Recommended learning: Redis Video Tutorial)

These data types all support push/pop, add/remove, intersection, union, difference and richer operations, and these operations are It's atomic.

On this basis, redis supports various sorting methods. Like memcached, data is cached in memory to ensure efficiency.

Redis (full name: Remote Dictionary Server Remote Dictionary Service) is an open source log-type, Key-Value written in ANSI C language, supports the network, and can be memory-based and persistent. Database and provides APIs in multiple languages.

Storage

Redis uses two file formats: full data and incremental requests.

The full data format is to write the data in the memory to the disk to facilitate the next reading of the file for loading;

The incremental request file is to serialize the data in the memory It is an operation request, used to read files and replay to obtain data. Serialization operations include SET, RPUSH, SADD, and ZADD.

The storage of redis is divided into three parts: memory storage, disk storage and log file. There are three parameters in the configuration file to configure it.

save seconds updates, save configuration, indicates how many update operations there are within a long period of time, and then synchronizes the data to the data file. This can be matched with multiple conditions. For example, the settings in the default configuration file set three conditions.

appendonly yes/no, appendonly configuration, indicates whether to log after each update operation. If not enabled, data may be lost for a period of time during a power outage. Because redis's own synchronized data files are synchronized according to the above save conditions, some data will only exist in memory for a period of time.

appendfsync no/always/everysec, appendfsync configuration, no means waiting for the operating system to synchronize the data cache to the disk, always means manually calling fsync() after each update operation to write the data to Disk, everysec means synchronization every second.

For more Redis-related technical articles, please visit the Redis Getting Started Tutorial column to learn!

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

Statement:
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