What if the memory required by Redis exceeds the available memory?

Source: Internet
Author: User

What if the memory required by Redis exceeds the available memory?

We know that redis sets the configuration fileMaxmemoryParameter to control the maximum available memory size (in bytes ).

When the required memory exceedsMaxmemoryWhat should I do?

In this configuration fileMaxmemory-policyNow.

The default value isNoeviction.

Below I will list the elimination rules for deleting the redis key when the available memory is insufficient.

 

Rule name Rule Description
Volatile-lru Use the LRU algorithm to delete a key (only the key with a life time set)
Allkeys-lru Deletes a key using the LRU algorithm.
Volatile-random Delete a random key (only the key with a life time set)
Allkeys-random Randomly delete a key
Volatile-ttl Deletes the key closest to the life cycle.
Noeviction If the key is not deleted, only an error is returned.

LRU Algorithm, Least Recently Used,Least recently used algorithms. That is to say, the least recently used keys are deleted by default.

HoweverBe sure to note that! Redis does not accurately Delete the least recently used keys among all keys, but randomly selectsThree keysDelete the least recently used keys among the three keys.

The number 3 can also be set. The corresponding location is in the configuration file.Maxmeory-samples.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.