【发布时间】:2023-03-22 05:29:01
【问题描述】:
在 Redis.conf 中,提供了各种关键的驱逐策略,以及它们如何工作的一些基础知识。
我想我想使用volatile-ttl,但我找不到足够的信息来说明它是如何工作的。
从表面上看,很明显;具有最近到期时间的密钥首先出现。如果 Redis 驱逐具有过期时间的 所有 键怎么办?假设它仍然需要继续驱逐以保持在maxmemory 之下,那么它在驱逐旁边选择什么?
# MAXMEMORY POLICY: how Redis will select what to remove when maxmemory
# is reached. You can select among five behaviors:
#
# volatile-lru -> remove the key with an expire set using an LRU algorithm
# allkeys-lru -> remove any key according 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 an error on write operations
【问题讨论】:
标签: redis