...# The range is tetween 1 and 500, however a value over 100 is usually not# a good idea. Most users should use the default of 10 and raise this up to# 100 only in environments where very low latency is requiried.hz 10...在这个参数的上面解释可以看出,建议不要将这个值设置超过100,一样平常使用默认的10,只有当在必要非常低延长的场景才设置为100。
2、Redis惰性删除战略
# In short... if you have slaves attached it is suggested that you set a lower# limit for maxmemory so that there is some free RAM on the system for slave# output buffers (but this is not needed if the policy is 'noeviction').#maxmemory <bytes># 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 operationsRedis可以设置内存巨细:maxmemory 100mb,超过了这个内存巨细,就会触发内存镌汰机制;
设置:在redis.conf 设置文件中,可以设置镌汰方式:maxmemory-policy noeviction
Redis 4.0开始,共有8种数据镌汰机制:见Redis的设置文件redis.conf: