当前位置: 首页 > news >正文

我国市级网站建设分析模板长沙关键词优化公司电话

我国市级网站建设分析模板,长沙关键词优化公司电话,如何查看一个网站是用什么cms做的,婚礼摄影作品网站Redis会因为内存不足而产生错误,也会因为回收过久而导致系统长期的停顿,因此了解掌握Redis的回收策略十分重要。当Redis的内存达到规定的最大值时,可以进行配置进行淘汰键值,并且将一些键值对进行回收。 我们打开Redis安装目录下…

Redis会因为内存不足而产生错误,也会因为回收过久而导致系统长期的停顿,因此了解掌握Redis的回收策略十分重要。当Redis的内存达到规定的最大值时,可以进行配置进行淘汰键值,并且将一些键值对进行回收。

我们打开Redis安装目录下的redis.conf文件。配置文件中有这么一段话

# Set a memory usage limit to 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).
#
# If Redis can't remove keys according to the policy, or if the policy is
# set to 'noeviction', Redis will start to reply with errors to commands
# that would use more memory, like SET, LPUSH, and so on, and will continue
# to reply to read-only commands like GET.
#
# This option is usually useful when using Redis as an LRU or LFU cache, or to
# set a hard memory limit for an instance (using the 'noeviction' policy).
#
# WARNING: If you have slaves attached to an instance with maxmemory on,
# the size of the output buffers needed to feed the slaves are subtracted
# from the used memory count, so that network problems / resyncs will
# not trigger a loop where keys are evicted, and in turn the output
# buffer of slaves is full with DELs of keys evicted triggering the deletion
# of more keys, and so forth until the database is completely emptied.
#
# 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 -> Evict using approximated LRU among the keys with an expire set.
# allkeys-lru -> Evict any key using approximated LRU.
# volatile-lfu -> Evict using approximated LFU among the keys with an expire set.
# allkeys-lfu -> Evict any key using approximated LFU.
# volatile-random -> Remove a random key among the ones 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 evict anything, just return an error on write operations.
#
# LRU means Least Recently Used
# LFU means Least Frequently Used
#
# Both LRU, LFU and volatile-ttl are implemented using approximated
# randomized algorithms.
#
# Note: with any of the above policies, Redis will return an error on write
#       operations, when there are no suitable keys for eviction.
#
#       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:
#
# maxmemory-policy noeviction# LRU, LFU 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.
#
# The default of 5 produces good enough results. 10 Approximates very closely
# true LRU but costs more CPU. 3 is faster but not very accurate.
#
# maxmemory-samples 5
  • volatile-lru:采用最近使用最少的淘汰策略,Redis将回收那些超时的(仅仅是超时的)键值对,也就是它只淘汰那些超时的键值对。

  • allkeys-lru:采用最近最少使用的淘汰策略,Redis将对所有(不仅仅是超时的)的键值对采用最近最少使用的淘汰策略。

  • volatile-lfu:采用最近最不常用的淘汰策略,所谓最近最不常用,也就是一定时期内被访问次数最少的。Redis将回收超时的键值对。

  • allkeys-lfu:采用最近最不常用的淘汰策略,Redis将对所有的键值对采用最近最不常用的淘汰策略。

  • volatile-random:采用随机淘汰策略删除超时的键值对。

  • allkeys-random:采用随机淘汰策略删除所有的键值对,这个策略不常用。

  • volatile-ttl:采用删除存活时间最短的键值对策略。

  • noeviction:不淘汰任何键值对,当内存满时,如果进行读操作,例如get命令,它将正常工作,而做写操作,它将返回错误,也就是说,当Redis采用这个策略内存达到最大的时候,它就只能读不能写了。

Redis默认采用noeviction策略。

LRU算法或者TTL算法都是不精确的算法,而是一个近似算法。

Redis不会通过对全部的键值对进行比较来确定最精确的时间值,因为这太消耗时间,导致回收垃圾占用的时间太多造成服务器卡顿。在配置文件中,有一个参数maxmemory-samples,它的默认值是5,如果采用volatile-ttl算法,我们可以看看下面这个过程,假设有7个即将超时的键值对

键值对剩余超时秒数备注
A16属于探测样本
A23属于探测样本
A34属于探测样本
A45属于探测样本
A52属于探测样本中的最小值,因此最先删除
A61虽然是最短值,但不属于探测样本,因此没有被删除

当设置maxmemory-samples越大,则Redis删除的就越精确,但消耗CPU。

回收超时策略的缺点是必须指明超时的键值对,这会给程序开发带来一些设置超时的代码,增加刘开发者的工作量。对所有的键值对进行回收,有可能把正在使用的键值对删掉,增加了存储的不稳定性。对于垃圾回收的策略,还需要控制回收的时间。

http://www.lbrq.cn/news/2706175.html

相关文章:

  • 玉环住房与城乡建设规划局网站成人电脑培训班办公软件
  • 有哪些开发网站公司营销推广平台
  • 谁做的12306网站关键词查询
  • 东莞网站建设制作公司排名成都自动seo
  • 峰峰做网站小游戏推广接单平台
  • 做网站编辑累吗百度点击优化
  • 个人备案的网站可以做宣传广西壮族自治区免费百度推广
  • 安康网站建设百度关键词收录
  • 如何做免费网站推广锦州网站seo
  • 合肥做网站拉新推广怎么快速拉人
  • 做网站的原型 免费网络推广费用大概价格
  • 宝安网站设计制作商务软文写作300字
  • 知名广告公司有哪些东莞百度seo推广公司
  • 外包网站怎么做seo搜索引擎优化的核心及内容
  • 自己如何做独立网站保定百度seo排名
  • 模板网站不可以做seo优化吗公司网站设计模板
  • 网站部分网页乱码各种推广平台
  • 广州市网站搭建制作湖南竞价优化专业公司
  • 代卖货平台seo实战培训中心
  • 律师网站建设方案专业黑帽seo
  • 推广普通话手抄报图片大全seo站内优化包括
  • 亚当学院网站视频建设教程长沙seo男团
  • 合肥网站开发百度官方网站网址是多少
  • 深圳网站建设设搜索引擎优化教材答案
  • 网站做营利性广告需要什么备案网址收录大全
  • 网站无法连接到服务器手机app安装下载
  • 东莞 网站建设收费杭州哪家seo公司好
  • 做网站会不会亏本直通车官网
  • dw网站的滑屏怎么做网络营销七个步骤
  • 苏州旅游网站设计外贸互联网推广的
  • GoLand 项目从 0 到 1:第八天 ——GORM 命名策略陷阱与 Go 项目启动慢问题攻坚
  • 数据结构:后缀表达式:结合性 (Associativity) 与一元运算符 (Unary Operators)
  • 【数据库】 MySQL 表的操作详解
  • 11. React组件插槽用法
  • GPT-5 全面解析与最佳实践指南
  • 达梦数据库慢SQL日志收集和分析