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

商业网站设计方案模板代写文章的平台有哪些

商业网站设计方案模板,代写文章的平台有哪些,网站开发和网站建设,可以做微信游戏的网站这里要讨论的为过期的数据是如何被清除的,也就是网上常常讨论的过期清除策略。 需要注意的是,redis除了会对过期的数据进行淘汰,也可以通过对内存大小进行限制,并对超出内存限制后进行数据淘汰。此时淘汰的数据未必是过期的&…

这里要讨论的为过期的数据是如何被清除的,也就是网上常常讨论的过期清除策略。

需要注意的是,redis除了会对过期的数据进行淘汰,也可以通过对内存大小进行限制,并对超出内存限制后进行数据淘汰。此时淘汰的数据未必是过期的,只是因为内存达到限制而被淘汰。需要注意一下两者的区别,数据淘汰算法包括LRU、LFU等。

好,回归过期数据清除策略这里。redis的数据清除策略包括2种。惰性清除和定期清除。

惰性清除很简单,redis会在用户访问数据时,如果发现数据是过期的,那么就删除这个数据,并且给用户返回相应的结果。那么redis是如何发现这个数据是过期的呢?我们知道redis默认有16个库,0~15号库,每一个库对应源码中的一个db结构体,db中有一个dict类型成员变量expire,dict,即字典,也就是哈希表,是redis底层数据结构中的一种,expire哈希表中存储的键值对,key为键,value为其对应的过期时间,expire中存储了该库中所有键的过期时间。

那么定期清除呢?我们先贴上一段redis配置文件中的文字。

# Redis reclaims expired keys in two ways: upon access when those keys are
# found to be expired, and also in background, in what is called the
# "active expire key". The key space is slowly and interactively scanned
# looking for expired keys to reclaim, so that it is possible to free memory
# of keys that are expired and will never be accessed again in a short time.
#
(redis通过2种方法清除过期键:在操作时发现这些key是过期的,还有也是通过后台清除的,被称作'定期清除key'。key空间被缓慢的、交互式的清除过期键,所以它可能会清除过期的key来释放内存,并且短时间不会被再次访问)# The default effort of the expire cycle will try to avoid having more than
# ten percent of expired keys still in memory, and will try to avoid consuming
# more than 25% of total memory and to add latency to the system. However
# it is possible to increase the expire "effort" that is normally set to
# "1", to a greater value, up to the value "10". At its maximum value the
# system will use more CPU, longer cycles (and technically may introduce
# more latency), and will tolerate less already expired keys still present
# in the system. It's a tradeoff between memory, CPU and latency.
#
(清除循环作为一种默认的尝试,会尝试避免在内存中存在超过10%的过期Key,并且避免(过期key占用的内存)超过总内存的25%,最终将内存归还系统。它可以增加这种清除的尝试,通常它会被设置为1,到一个更大的值,最大可以达到10。它的最大值意味着系统会使用更的的cpu资源,更久的循环时间(理论上可能会导致延迟),并且容忍更少的现在存在于系统中的过期的key。它是一种在内存、CPU、延迟之间的一种平衡和折衷)
# active-expire-effort 1

也就是说redis定期清除会主动的进行清除。active-expire-effort控制了每次循环的时间有多长。清除达标的条件为避免在内存中存在超过10%的过期Key,并且避免(过期key占用的内存)超过总内存的25%。不达标的话会继续循环清除,直到达标为止。

另外一个参数hz控制了诸如清除循环、关闭超时客户端等后台任务的频率。综合控制了定期清除的行为。
hz相关注释如下:

# Redis calls an internal function to perform many background tasks, like
# closing connections of clients in timeout, purging expired keys that are
# never requested, and so forth.
#
# Not all tasks are performed with the same frequency, but Redis checks for
# tasks to perform according to the specified "hz" value.
#
# By default "hz" is set to 10. Raising the value will use more CPU when
# Redis is idle, but at the same time will make Redis more responsive when
# there are many keys expiring at the same time, and timeouts may be
# handled with more precision.
#
# The range is between 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 required.
hz 10

参考文章:
[1],Redis(6)删除策略(定时删除、惰性删除、定期删除)和数据逐出策略

http://www.yidumall.com/news/55139.html

相关文章:

  • 公司网站建设合同模板下载网络营销的推广方式
  • 2018企业网站优化应该怎么做100个免费推广b站
  • 网站框架一般用什么做免费推广网站地址大全
  • 企业网站空间选择百度搜索引擎优化方式
  • magento做预订类网站网址大全浏览器主页
  • asp.net网站开发菜鸟如何获取热搜关键词
  • 规则网站建设我在百度下的订单如何查询
  • 服装网站建设的技术可行性郑州官网网络营销外包
  • 网页设计的网站推荐网络公关
  • 青岛谁家做网站百度seo查询收录查询
  • 属于您自己的网站建设百度seo系统
  • div+css网站模板网络推广员是什么工作
  • 南昌网站建设推广专家免费发布推广信息的平台有哪些
  • 自己做的网站怎样链接数据库怎么自己建网站
  • 用node.js可以做网站吗网站建设制作流程
  • 甘肃省专业做网站百度品牌推广
  • 淘客网站怎么备案网站seo去哪个网站找好
  • b2c旅游网站建设销售的技巧与口才
  • 工商注册图片太原关键词排名优化
  • 营销型网站的优点微信引流获客软件
  • 云服务器可以做两个网站谷歌搜索引擎营销
  • b2b网站一个人可以做吗收录批量查询
  • 泉州做网站的公司账号权重查询
  • 网站建设服百度关键词seo公司
  • 移动互联网应用程序开发百家号关键词排名优化
  • 宜昌建设银行网站营销号
  • 西安新能源网站建设优化关键词的正确方法
  • 哪个网站做公司业务广告效果好百度客服电话人工服务热线
  • 余姚的网站建设网站关键词免费优化
  • 北京做网站便宜的公司哪家好360收录查询