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

php做的网站首页是什么文件夹怎么做加密网站

php做的网站首页是什么文件夹,怎么做加密网站,网站开发公司徐州,网站app的区别是什么意思聊聊 Redis 过期键的删除策略 答案 惰性删除 #xff1a;只会在取出 key 的时候才对数据进行过期检查#xff1b;这样对 CPU 最友好#xff0c;但是可能会造成太多过期 key 没有被删除#xff08;占用内存#xff09;。 通过定时器实现#xff08;时间事件#xff09;只会在取出 key 的时候才对数据进行过期检查这样对 CPU 最友好但是可能会造成太多过期 key 没有被删除占用内存。 通过定时器实现时间事件时间事件是通过无序链表实现的查询复杂度为 O(N) 数据到达过期时间不做处理每次访问该数据时我们需要实时判断 源码路径db.c/expireIfNeeded()本质上 expireIfNeeded 方法类似于过滤器 7.2 版本只会返回 0/1 0 有效 1 过期 定时删除 每隔一段时间抽取一批 key 执行删除过期 key 操作。并且Redis 底层会通过限制删除操作执行的时长和频率来减少删除操作对 CPU 时间的影响。 默认情况下 Redis 定期检查的频率是每秒扫描 10 次用于定期清除过期键。当然此值还可以通过配置文件进行设置在 redis.conf 中修改配置 hz 即可默认的值为 hz 10官方注释范围为 1~500但建议最大 100 即可 定时删除的扫描并不是遍历所有的键值对这样的话比较费时且太消耗系统资源。Redis 服务器采用的是随机抽取形式每次从过期字典中取出 20 个键进行过期检测过期字典中存储的是所有设置了过期时间的键值对。如果这批随机检查的数据中有 25% 的比例过期那么会再抽取 20 个随机键值进行检测和删除并且会循环执行这个流程直到抽取的这批数据中过期键值小于 25%此次检测才算完成 Redis 服务器为了保证过期删除策略不会导致线程卡死会给过期扫描增加了最大执行时间为 25ms 定期删除对内存更加友好惰性删除对 CPU 更加友好 总结所以 Redis 采用的是 定时删除惰性删除 可以简称为 定期删除 源码路径server.c/activeExpireCycle() ps: 本文源码内容基于 7.2 版本 引申内容源码解析 内存数据库redisDb /* Redis database representation. There are multiple databases identified* by integers from 0 (the default database) up to the max configured* database. The database number is the id field in the structure. */ typedef struct redisDb {dict *dict; /* The keyspace for this DB 所有数据的键值对 */dict *expires; /* Timeout of keys with a timeout set 设置了超时时间的相关键值对数据 */dict *blocking_keys; /* Keys with clients waiting for data (BLPOP) 阻塞的 dict */dict *blocking_keys_unblock_on_nokey; /* Keys with clients waiting for* data, and should be unblocked if key is deleted (XREADEDGROUP).* This is a subset of blocking_keys 解除阻塞的dict */dict *ready_keys; /* Blocked keys that received a PUSH */dict *watched_keys; /* WATCHED keys for MULTI/EXEC CAS 监控的dict 事务前可以加watch */int id; /* Database ID */long long avg_ttl; /* Average TTL, just for stats */unsigned long expires_cursor; /* Cursor of the active expire cycle. */list *defrag_later; /* List of key names to attempt to defrag one by one, gradually. */clusterSlotToKeyMapping *slots_to_keys; /* Array of slots to keys. Only used in cluster mode (db 0). */ } redisDb;键值对dict struct dict {dictType *type; /* 键值对的类型 */dictEntry **ht_table[2]; /* 两张哈希表目的为了 rehash */unsigned long ht_used[2]; /* 上面两张哈希表中分别使用了多少 *//* rehash 的目的是重新进行扩展或收缩 */long rehashidx; /* rehashing not in progress if rehashidx -1记录 rehash 进度的标志每移动一个桶,rehashidx *//* Keep small vars at end for optimal (minimal) struct padding */int16_t pauserehash; /* If 0 rehashing is paused (0 indicates coding error) rehash是否暂停 */signed char ht_size_exp[2]; /* exponent of size. (size 1exp) 目的 加快运算速度*/void *metadata[]; /* An arbitrary number of bytes (starting at a* pointer-aligned address) of size as defined* by dictTypes dictEntryBytes. */ };键值对实体dictEntry存放键值对 struct dictEntry {void *key;union {void *val;uint64_t u64;int64_t s64;double d;} v;struct dictEntry *next; /* Next entry in the same hash bucket. 哈希值相同的key/val对出现哈希冲突时通过链表存储起来 */void *metadata[]; /* An arbitrary number of bytes (starting at a* pointer-aligned address) of size as returned* by dictTypes dictEntryMetadataBytes(). */ };哈希数据类型 dictType 存放函数的结构体定义了一些函数指针目的: 通过设置自定义函数使得 dict 的 key 和 value 能够存储任何类型的数据 typedef struct dictType {uint64_t (*hashFunction)(const void *key);void *(*keyDup)(dict *d, const void *key);void *(*valDup)(dict *d, const void *obj);int (*keyCompare)(dict *d, const void *key1, const void *key2);void (*keyDestructor)(dict *d, void *key);void (*valDestructor)(dict *d, void *obj);int (*expandAllowed)(size_t moreMem, double usedRatio);/* Flags *//* The no_value flag, if set, indicates that values are not used, i.e. the* dict is a set. When this flag is set, its not possible to access the* value of a dictEntry and its also impossible to use dictSetKey(). Entry* metadata can also not be used. */unsigned int no_value:1;/* If no_value 1 and all keys are odd (LSB1), setting keys_are_odd 1* enables one more optimization: to store a key without an allocated* dictEntry. */unsigned int keys_are_odd:1;/* TODO: Add a keys_are_even flag and use a similar optimization if that* flag is set. *//* Allow each dict and dictEntry to carry extra caller-defined metadata. The* extra memory is initialized to 0 when allocated. */size_t (*dictEntryMetadataBytes)(dict *d);size_t (*dictMetadataBytes)(void);/* Optional callback called after an entry has been reallocated (due to* active defrag). Only called if the entry has metadata. */void (*afterReplaceEntry)(dict *d, dictEntry *entry); } dictType;
http://www.dnsts.com.cn/news/177523.html

相关文章:

  • 网站建设怎样找客户施工企业项目管理中心岗位职责
  • 公维金如何上传建设局网站杭州物联网前十名公司
  • 推广网站的方法有搜索莱芜房产网站
  • 口碑好的高密网站建设wordpress 网站标题图
  • 中山企业推广网站制作如何让一个网站排名掉
  • sae安装WordPress4.4东莞seo网络营销策划
  • 文字图片制作网站域名服务器分为
  • 网站的ico图标做多大深圳建站模板公司
  • 电商网站项目经验介绍金蝶财务软件官网首页
  • 视觉传达毕业设计作品网站wordpress 资讯
  • 网站推广方案怎么写的个人网站设计开题报告
  • 个人免费网站空间搭建一个网站教程
  • 设计网站要多久深圳罗湖做网站的公司
  • 电子商务网站建设与管理的重要性石家庄论坛建站模板
  • 文章修改网站内蒙古优途国际旅行社
  • 临西网站建设费用云主机网站如何备份
  • 做建材营销型网站橙色大气风格网站模板
  • 抖音小程序源码做网站优化步骤
  • 网站开发现在怎么样搜索引擎优化的定义是什么
  • google网站增加关键词WordPress微博qq登录插件
  • 2免费做网站中国房地产未来走势
  • 旅游网站改版方案做网站的硬件和软件环境
  • 外贸开发网站公司四川省建设厅官方网站首页
  • 南阳住房和城乡建设管理局网站canvas设计网站
  • 仪征建设局招投标网站设计网页价格
  • 公路水运建设质量与安全监督系统网站优秀设计案例网站
  • 7天精通网站建设实录简介242网站后期维护收费
  • 大连网站建设仟亿做盗版网站
  • 天津企业模板建站哪个好公司网站案例展示
  • 用dw做网站流程一个完整网站开发需要什么技术