Redis Expiration Policy

Source: Internet
Author: User
Tags allkeys


One, the Redis key has six kinds of expiration policy

1. Noeviction: Returns error once memory is full

2, ALLKEYS-LRU: All the key to the LRU

3, VOLATILE-LRU: only to set the expired key for LRU (the default way)

4, Allkeys-random: Randomly remove a key

5, Volatile-random: To set the expiration of the key to random culling a

6, Volatile-ttl: Delete the expiring key

According to the official website, the LRU used by Redis is not a real LRU algorithm, and the accuracy is not high. The redis3.0 version of LRU will maintain a candidate pool, which will perform better.


ii. settings and viewing of some memory and expiration policies

1, set the memory size of the instance (local execution can not use-h $host, the unit is B)

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

2. Get the memory size of the instance

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

3. Set Expiration policy

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

4. View Expiration policy

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


Description: After testing the Volatile-lru, it is true that if there is a key that has an expiration time set, the LRU will be executed and the insertion can continue. If you don't have a key with expiration time set, you will get an error.






Redis Expiration Policy

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.