Redis LRU Cache cleanup algorithm for detailed understanding and related configuration

Source: Internet
Author: User
Tags allkeys volatile

First, you need to configure the Redis conf file, which involves the LRU related configuration A total of three are:

    1. MaxMemory, sets the maximum memory size that Redis uses to hold data, and once it exceeds this memory size, it immediately cleans up some of the data using the LRU algorithm

    2. Maxmemory-policy, you can set the memory to the maximum idle, what policy to take to handle


      (1) Noeviction: If the memory is used to reach maxmemory,client and continue to write data, then directly error to the client

      (2) Allkeys-lru: Is what we often call the LRU algorithm, remove the least recently used keys corresponding data, PS the longest use of the strategy

      (3) Volatile-lru: Also take the LRU algorithm, but only for those setting the specified time-to-live (TTL) key will be cleaned out

      (4) Allkeys-random: Randomly select some key to delete

      (5) Volatile-random: Randomly select some keys with TTL set to delete

      (6) Volatile-ttl: Remove some keys and select the keys that have a shorter TTL time

    3. LRU uses the approximate algorithm, starting from 3.0 LRU algorithm introduced the pool mechanism, the performance can be comparable with the real LRU algorithm, after sampling the LRU cleanup and the traditional full-volume LRU slightly different.

      Configuration using Maxmemory-samples, such as 5, can set the size of the sample, if set to 10, then the effect is better, but also consumes more CPU resources


This is the explanation for the Redis LRU cache cleanup related issues.

Redis LRU Cache cleanup algorithm for detailed understanding and related configuration

Related Article

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.