Home  >  Article  >  Database  >  What is the redis data elimination strategy?

What is the redis data elimination strategy?

藏色散人
藏色散人forward
2020-09-08 09:24:482106browse

The following column Redis Tutorial will introduce the redis data elimination strategy to you. I hope it will be helpful to friends in need!

What is the redis data elimination strategy?

#1. Introduction to elimination

Redis official warning: when there is insufficient memory, Redis will be eliminated according to the configured cache strategy. Some keys to ensure successful writing. When there is no elimination strategy or no key suitable for elimination is found, Redis directly returns an out of memory error.

2, Maximum cache configuration

In redis, the maximum memory size allowed to be set by users is 512G.

In redis, users are allowed to set the maximum memory size server.maxmemory, which is very useful when memory is limited. For example, 4 redis service points are deployed on an 8G machine, and each service point is allocated a memory size of 1.5G to reduce memory constraints and obtain more robust services.

3, 6 data elimination strategies

1, volatile-lru: From the data set with expiration time set (server.db[ i].expires), select the least recently used data to eliminate

2. volatile-ttl: From the data set with the expiration time set (server.db[ i].expires), select the data to be expired

3. Volatile-random: Select the data set with expiration time set from ].expires), select any data to eliminate

4. allkeys-lru: Select the least recent data from the data set (server.db[i].dict) Used data elimination

5, allkeys-random: Select any data from the data set (server.db[i].dict) for elimination

6. no-enviction (eviction): prohibit eviction data

4.Suggestion

After understanding the elimination strategy of Redis, you should try your best to actively set/update the expire time of the key during daily use, and actively eliminate inactive old data, which will help improve query performance.

Redis expired data elimination means deleting all key-value pairs, please understand! ! ! ! ! ! ! ! ! ! ! ! !

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

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete