Redis expiration Policy, redis expired

Source: Internet
Author: User
Tags allkeys

Redis expiration Policy, redis expired


I. redis keys have six expiration policies

1. noeviction: Once the memory is full, an error is returned.

2. allkeys-lru: Perform LRU on all keys

3. volatile-lru: Only LRU is performed on expired keys (default)

4. allkeys-random: Randomly removes a key.

5. volatile-random: Randomly removes an expired key.

6. volatile-ttl: Delete the expired key

According to the official website, the LRU used by redis is not a real LRU algorithm, and the accuracy is not high. LRU of redis3.0 maintains a candidate pool, which improves performance.


Ii. Set and view memory and expiration policies

1. Set the memory size of the Instance (-h $ host is not required for local execution, and the Unit is B)

Redis-cli-h $ host-p $ port config set maxmemory 1024

2. Obtain the memory size of the instance.

Redis-cli-h $ host-p $ port config get maxmemory

3. Set an expiration Policy

Redis-cli-h $ host-p $ port config set maxmemory-policy volatile-lru

4. view the expiration Policy

Redis-cli-h $ host-p $ port config get maxmemory-policy


Note: volatile-lru has been tested. If a key with an expiration time is set, LRU is executed and can be inserted. If no key with an expiration time is set, an error is returned.






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.