The LRU mechanism of Redis

Source: Internet
Author: User
Tags allkeys

Original: The LRU mechanism of Redis

In Redis, if you set the MaxMemory, it is necessary to configure the key recycle mechanism parameter maxmemory-policy, default VOLATILE-LRU, see the original blog of the Redis Author: Antirez Weblog >> Redis As an LRU cache

The original text is clearly written:

Another-use Redis as a cache is the maxmemory directive, a feature that allows specifying a maximum amount of memory to use. When new data are added to the server, and the memory limit was already reached, the server would remove some old data delet ing a volatile key, that's, a key with an EXPIRE (a timeout) set, even if the key was still far from expiring AUT Omatically.

When the Redis server consumes memory up to MaxMemory, when you want to increase the memory footprint, the old data is deleted by the maxmemory-policy mechanism. Here's a quick Volatile-lru,redis. The LRU algorithm removes the key that set the expiration time but has not expired, and the Key,redis that has not set the expiration time is always preserved. Of course, if you don't want to delete a key that doesn't expire, you can use the noeviction mechanism

# maxmemory Policy:how Redis would select what to remove when maxmemory

# is reached? You can select among five behavior:
#
# VOLATILE-LRU, remove the key with a expire set using an LRU algorithm
# ALLKEYS-LRU, remove any key accordingly to the LRU algorithm
# volatile-random, remove a random key with an expire set
# allkeys-random, remove a random key, any key
# Volatile-ttl, remove the key with the nearest Expire time (minor TTL)
# noeviction, don ' t expire at all, just return a error on write operations

The LRU mechanism of Redis (GO)

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.