Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Introduction to redis service & & detailed explanation of redis.conf profile

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

# 1. Introduction to redis service

Redis is a key-value storage system. Similar to Memcached, it supports relatively more value types for storage (memcached does not support value types, only key), including string (strings), list (linked lists), set (collections), and zset (ordered sets). These data types support push/pop, add/remove, and take intersection union and difference sets, and richer operations, and these operations are atomic. On this basis, redis supports a variety of different sorting methods. Like memcached, data is cached in memory for efficiency. The difference is that redis will periodically write updated data to disk or modify operations to additional record files, and on this basis to achieve master-slave (master-slave) synchronization. Therefore, redis can still save the user session cache in the event of a power outage, but the session cache is lost after a power outage of memcached.

The function of session cache: session is mainly used to store the user's login information. When a user logs in, as long as there is a record in the session, it is judged to be logged in status without additional login operation. If the user information is not in session, it is judged that the user name and password need to be entered for login operation. If you log in to the submitted data, you must first make a matching query in the database. If the user information is found, the database returns the result and writes the corresponding user information to session as the judgment of the next user login status.

Databases that mainly store session: redis, memcached (nosql database)

Redis&memcached comparison:

Redis writes the data to disk and keeps the data all the time synchronously, so the session can be saved after a power outage. However, memcached only stores the user's login information in the cache. If the power is cut off, the session information is lost and the database query needs to be redone. It is precisely because the data is only stored in the cache, and there is no need for master-slave synchronization with the disk to keep the data consistent, so the process of user login status is very fast.

In addition, redis supports key,value and other types of data storage, while memcached only supports key. So redis can be used in a wider range.

Redis is a non-relational data storage tool, which is different from the traditional relational database (such as mysql, etc.), similar to memcache, and it integrates the operation of list (linked list) and set (collection), which can easily and quickly deal with data (such as inserting and deleting list to take intersection and set difference, etc.), which greatly reduces the pressure on the underlying database and gives users faster response speed.

# II. / etc/redis.conf configuration file

Whether daemonize runs as a background process. If nopidfile runs as a background process, you need to specify a pid. Default is / var/run/redis.pidbind binding host IP, default is 127.0.0.1 (comment) port listening port, default is 6379timeout timeout, default is 300 (seconds) loglevel logging level. There are four optional values, debug,verbose (default), notice,warninglogfile logging method. The default value is the number of databases available in stdoutdatabases. The default value is 16. The default database is 0save, which indicates that the data will be synchronized to the data file within a long period of time and how many updates there are. This can be matched by multiple conditions, such as the settings in the default configuration file, which set three conditions. At least one key is changed in save 9001,900 seconds (15 minutes) save 300 10300 seconds (5 minutes) at least 300 key is changed save 60 10000 at least 10000 key is changed in 60 seconds whether the data is compressed when rdbcompression is stored in the local database, default is yesdbfilename local database file name, default is dump.rdbdir local database storage path Default is. / slaveof when the machine is a slave service, set the IP and port (comment) masterauth of the master service. When the machine is a slave service, set the connection password of the master service (comment) requirepass connection password (comment) maxclients maximum number of client connections, default does not limit (comment) maxmemory sets the maximum memory After reaching the maximum memory setting, Redis will first try to clear the expired or about to expire Key, and after this method has been processed, any write operation can no longer be performed if the maximum memory setting is reached. (note) whether appendonly logs after each update operation, if it is not enabled, it may result in data loss for a period of time in the event of a power outage. Because redis itself synchronizes data files according to the above save conditions, some data will only exist in memory for a period of time. The default value is the noappendfilename update log file name, and the default value is appendonly.aof (comment) appendfsync update log condition. There are 3 optional values. No means that the operating system synchronizes the data cache to disk, always means to manually call fsync () to write data to disk after each update operation, and everysec means to synchronize once a second (the default). Whether vm-enabled uses virtual memory. Default is novm-swap-file virtual memory file path, and default is / tmp/redis.swap. Cannot be shared by multiple Redis instances. Vm-max-memory stores all data larger than vm-max-memory in virtual memory. No matter how small the vm-max-memory setting is, all index data is stored in memory (the index data of Redis is keys), that is, when vm-max-memory is set to 0, all value actually exists on disk. The default value is 0.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report