This article is a mirror article of machine translation, please click here to jump to the original article.

View: 3272|Reply: 0

[Redis] Redis memory eight elimination strategies

[Copy link]
Posted on 7/12/2023 9:08:41 PM | | |
Redis can passmaxmemory parameter to limit memory usage, the default value is 0, which means that the use of memory is not restricted. When the data memory reaches maxmemory, the redis memory retirement policy is triggered. This parameter is usually set to three-quarters of its physical memory.

Redis MISCONF Redis is configured to save RDB snapshots
https://www.itsvse.com/thread-9650-1-1.html

Common unit configurations

maxmemory 100 bare number case: The unit is bytes.
maxmemory 1K K: represents 1000 bytes.
maxmemory 1KB KB: represents 1024 bytes.
maxmemory 1M M: represents 1,000,000 bytes.
maxmemory 1MB MB: Represents 1048576 bytes.
maxmemory 1G G: represents 1000000000 bytes.
maxmemory 1GB GB: represents 1073741824 bytes.
The maxmemory parameter to limit redis maximum memory is generally used in conjunction with the maxmemory-policy memory retirement policy.

maxmemory-policy eight elimination strategies

  • noeviction:( after installationDefault policyWhen the memory usage exceeds the configuration, an error is returned and no keys are evicted.
  • allkeys-lru:(commonly used) when adding keys, if the limit is exceeded, the LRU algorithm is first used to expel the keys that have not been used for a long time.
  • volatile-lru: If the limit is exceeded when adding keys, first expel the keys that have not been used for a long time from the set of keys with an expiration time.
  • allkeys-random: If the limit is exceeded when adding keys, it will be randomly deleted from all keys.
  • volatile-random: If the limit is exceeded when adding keys, it will be randomly expelled from the set of expired keys.
  • volatile-ttl: Expels keys that are about to expire from keys that have an expiration time configured.
  • volatile-lfu: Expels the least frequently used key from all keys with an expiration time configured.
  • allkeys-lfu: Expels the least frequently used key from all keys


Official documentation:The hyperlink login is visible.

maxmemory and maxmemory-policy can generally be configured by modifying the .config file, of course, you can also connect to the redis server and configure it through the command as follows:

(End)





Previous:.NET/C# uses SqlConnectionStringBuilder to compare database connections
Next:ASP.NET MVC counts requests based on IHttpModule modules
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com