Home > Database > Redis > body text

What is the default expiration time of redis

silencement
Release: 2019-06-04 15:22:48
Original
23301 people have browsed it

What is the default expiration time of redis

1. Introduction to Redis database

The redis database is a memory-based, persistent key-value pair non-relational database. In order to ensure efficiency, redis data is cached in memory. The difference is that redis will periodically write updated data to disk or write modification operations to additional record files, and on this basis, master- slave (master-slave) synchronization.

Redis supports master-slave synchronization. Data can be synchronized from the master server to any number of slave servers, and the slave server can be a master server associated with other slave servers. This allows Redis to perform single-level tree replication. Saving can write data intentionally or unintentionally. Since the publish/subscribe mechanism is fully implemented, when the slave database synchronizes the tree anywhere, it can subscribe to a channel and receive the complete message release record of the master server. Synchronization is helpful for scalability and data redundancy of read operations.

Redis is a database based on memory management, so the memory overhead needs to be further optimized:

①. The first and most important point is not to enable the VM option of Redis, that is, the virtual memory function. This is originally It is a persistence strategy for Redis to store data beyond physical memory and swap it in and out of memory and disk. However, its memory management cost is also very high, and we will analyze later that this persistence strategy is not mature. So to turn off the VM function, please check that vm-enabled in your redis.conf file is no.

②. Secondly, it is best to set the maxmemory option in redis.conf. This option tells Redis to start rejecting subsequent write requests after how much physical memory is used. This parameter can be well protected. Your Redis will not cause swap due to the use of too much physical memory, which will eventually seriously affect performance or even crash.

③. If most of the data stored in Redis is numerical, Redis uses a shared integer internally to save the overhead of allocating memory, that is, when the system starts, it first allocates a value from 1 to n Then multiple numerical objects are placed in a pool. If the stored data happens to be within this numerical range, the object is taken directly from the pool and shared through reference counting. This way a large number of numerical values ​​are stored in the system. It can also save memory and improve performance to a certain extent

2. redis data storage location

We know that redis stores data based on memory, so the data is lost Data will be lost after power failure. We can also generate relevant log files through configuration and back up the data on disk. This way you can ensure that the data is still available when you turn on the computer next time.

3. Common data types of redis database have related operations

Common operations for setting expiration time:

EXPIRE Set the key’s survival time to ttl seconds

PEXPIRE Set the key's generation time to ttl milliseconds

EXPIREAT Set the key's expiration time to the timestamp in seconds represented by timestamp

PEXPIREAT Set the key's expiration time The expiration time is set to the timestamp in milliseconds represented by timestamp

The above is the detailed content of What is the default expiration time of redis. 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!