Redis - Evictions

2022/8/21 2:26:02

本文主要是介绍Redis - Evictions,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

This behavior is well known in the developer community, since it is the default behavior for the popular memcached system.

Maxmemory configuration directive

The maxmemory configuration directive configures Redis to use a specified amount of memory for the data set. You can set the configuration directive using the redis.conf file, or later using the CONFIG SET command at runtime.

Eviction policies

• noeviction: New values aren’t saved when memory limit is reached.
• allkeys-lru: Keeps most recently used keys; removes least recently used (LRU) keys
• allkeys-lfu: Keeps frequently used keys; removes least frequently used (LFU) keys
• volatile-lru: Removes least recently used keys with the expire field set to true.
• volatile-lfu: Removes least frequently used keys with the expire field set to true.
• allkeys-random: Randomly removes keys to make space for the new data added.
• volatile-random: Randomly removes keys with expire field set to true.
• volatile-ttl: Removes keys with expire field set to true and the shortest remaining time-to-live (TTL) value.

How the eviction process works

• A client runs a new command, resulting in more data added.
• Redis checks the memory usage, and if it is greater than the maxmemory limit , it evicts keys according to the policy.
• A new command is executed, and so forth.



这篇关于Redis - Evictions的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程