让星星⭐月亮告诉你,从Redis配置文件里一探Redis缓存清理策略的究竟

一、⭐⭐⭐Redis配置文件路径🌙🌙🌙

类似这样:D:\lib\redis\Redisx645010master\redis.windows.conf

二、⭐⭐⭐Redis缓存清理相关的注释及配置参数🌙🌙🌙

Don't use more memory than the specified amount of bytes.
When the memory limit is reached Redis will try to remove keys
according to the eviction policy selected (see maxmemory-policy).

不要使用超过指定字节量的内存。
当达到内存限制时,Redis将尝试删除键
根据所选的收回策略(参见maxmemory-policy)。

# maxmemory <bytes> #要设置的Redis可占用的最大内存

# MAXMEMORY POLICY: how Redis will select what to remove when maxmemory
# is reached. You can select among five behaviors:

达到最大内存占用时的缓存清理策略:你可以从以下五种行为里挑选,来决定Redis在到达最大内存占用时怎样挑选被删除的内存。

#
# volatile-lru -> remove the key with an expire set using an LRU algorithm
volatile-lru ->使用LRU(Least Recently Used最近最少使用)算法,从过期的键的集合中挑选一个要删除的键
# allkeys-lru -> remove any key according to the LRU algorithm
allkeys-lru ->使用LRU算法,从所有键中挑选一个要删除的键
# volatile-random -> remove a random key with an expire set
volatile-random ->从过期的键的集合中任意挑选一个要删除的键
# allkeys-random -> remove a random key, any key
allkeys-random -> 从所有键中任意挑选一个要删除的键
# volatile-ttl -> remove the key with the nearest expire time (minor TTL)
volatile-ttl -> 删除最接近到期时间的键(最小 Time To Live 生存时间)
# noeviction -> don't expire at all, just return an error on write operations
noeviction -> 根本就不会过期,只是在写操作时返回一个错误
#
# Note: with any of the above policies, Redis will return an error on write
#       operations, when there are no suitable keys for eviction.
使用以上任何一种策略,Redis都会在写时返回一个错误
在没有合适的键进行操作时。
#
#       At the date of writing these commands are: set setnx setex append
#       incr decr rpush lpush rpushx lpushx linsert lset rpoplpush sadd
#       sinter sinterstore sunion sunionstore sdiff sdiffstore zadd zincrby
#       zunionstore zinterstore hset hsetnx hmset hincrby incrby decrby
#       getset mset msetnx exec sort
#
# The default is: #默认缓存清理策略是noeviction
#
# maxmemory-policy noeviction

# LRU and minimal TTL algorithms are not precise algorithms but approximated
# algorithms (in order to save memory), so you can tune it for speed or
# accuracy. For default Redis will check five keys and pick the one that was
# used less recently, you can change the sample size using the following
# configuration directive.

LRU和最小TTL算法不是精确算法,而是近似算法(为了节省内存),因此您可以调整它的速度或精度。默认情况下,Redis会检查5个键,并选择一个最近使用较少的,你可以使用下面的配置指令来改变样本大小。

#
# The default of 5 produces good enough results. 10 Approximates very closely
# true LRU but costs a bit more CPU. 3 is very fast but not very accurate.
默认值5产生足够好的结果。10非常接近真实的LRU,但是花费更多一点的CPU。3是非常快,但不是非常准确。
#
# maxmemory-samples 5


三、⭐⭐⭐感慨🌙🌙🌙

优秀的产品,只看注释就让人有种爱不释手的感觉,清晰明了,不带歧义~ 爱了~

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Dylanioucn

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值