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

克拉玛依商城网站建设平台aso苹果关键词优化

克拉玛依商城网站建设平台,aso苹果关键词优化,网站信息化建设建议,做电商网站的框架结构图缓存淘汰策略 生产上redis内存设置为多少 设置为最大内存的 3/4 redis 会占用物理机多少内存 默认大小是 0,64 位系统下表示不限制内存大小,32位系统表示 3G 如何设置修改redis内存大小 config get maxmemory 查看修改方式 配置文件 单位是字节 2.…

缓存淘汰策略

生产上redis内存设置为多少

设置为最大内存的 3/4

redis 会占用物理机多少内存

默认大小是 0,64 位系统下表示不限制内存大小,32位系统表示 3G

如何设置修改redis内存大小

  1. config get maxmemory 查看
  2. 修改方式
    1. 配置文件 单位是字节

2. <font style="color:#000000;">临时修改,重启后失效 config set maxmemory 104857600</font>

如果redis内存满了会怎么样

redis 将会报错:(error) OOM command not allowed when used memory > ‘maxmemory’

通过命令查看 redis 内存使用情况?

info memory

redis 对于过期 key 的三种不同删除策略

定时删除:创建kv的同时cpu会创建定时器,内存友好,cpu占用高

惰性删除:再次访问这个 key 的时候才会去检查过期时间,内存不友好

定时删除:每隔一段时间去抽样扫描一定(注意不是所有)数量的key是否过期,并可通过限制执行的频率和时长来控制对 cpu 的影响,折中,但可能存留较多过期key,并且需要根据具体情况合适的设置频率和时长

如果执行时间太长,退化成定时。太短则又会出现过期key太多

引出兜底方案,缓存淘汰策略

redis 缓存淘汰策略

8种内存淘汰策略

  • noevition: 不操作 默认,看上面oom案例
  • allkeys-lru: 对所有 key 使用 lru
  • volatile-lru: 对所有设置了过期时间的key lru
  • allkeys-random
  • volatile-random
  • volatile-ttl: 删除快要过期
  • allkeys-lfu lfu
  • volatile-lfu

修改 -> maxmemory-policy

总结记忆

  1. 2个维度
    1. 过期键中筛选 allkeys
    2. 所有键中筛选 volatile
  2. 4个方面
    1. lru 最少使用,最长时间未被使用
    2. lfu 最不常用,一段时间内使用次数最少
    3. random 随机
    4. ttl

用哪种

后两种都对业务有精确的要求,推荐 allkeys-lru

lru算法手写,最近最少使用算法

leetcode 146

哈希链表

基于 LinkedHashMap 的写法

public class LruCacheDemo<K,V> extends LinkedHashMap<K,V> {private int capacity;public LruCacheDemo(int capacity) {super(capacity, 0.75f, false); // true = accessOrder false insertionOrderthis.capacity = capacity;}@Overrideprotected boolean removeEldestEntry(Map.Entry<K, V> eldest) {return super.size() > capacity;}public static void main(String[] args) {LruCacheDemo lruCacheDemo = new LruCacheDemo(3);lruCacheDemo.put(1, 1);lruCacheDemo.put(2, 2);lruCacheDemo.put(3, 3);System.out.println(lruCacheDemo.keySet());lruCacheDemo.put(4, 4);System.out.println(lruCacheDemo.keySet());lruCacheDemo.put(3, 3);System.out.println(lruCacheDemo.keySet());lruCacheDemo.put(3, 3);System.out.println(lruCacheDemo.keySet());lruCacheDemo.put(3, 3);System.out.println(lruCacheDemo.keySet());lruCacheDemo.put(5, 5);System.out.println(lruCacheDemo.keySet());}
}
/*** true* [1, 2, 3]* [2, 3, 4]* [2, 4, 3]* [2, 4, 3]* [2, 4, 3]* [4, 3, 5]*/
// false,只看插入顺序,不看访问顺序,多次插入3,3的位置不变
/*** false*[1, 2, 3]* [2, 3, 4]* [2, 3, 4]* [2, 3, 4]* [2, 3, 4]* [3, 4, 5]*/

手写的案例

// 手写 LruCache
public class MyLruCacheDemo {// map 负责查找,构建一个虚拟的双向链表,它里面安装的就是一个个Node节点,作为数据载体// 1 构造一个 Node 作为数据载体class Node<K, V> {K key;V value;Node<K, V> prev;Node<K, V> next;public Node() {this.prev = this.next = null;}}//2 构建一个虚拟的双向链表,里面安放的就是我们的Nodeclass DoubleLinkedList<K, V> {Node<K, V> head;Node<K, V> tail;// 2.1 构造方法public DoubleLinkedList() {head = new Node<K, V>();tail = new Node<K, V>();head.next = tail;tail.prev = head;}//2.2 添加到头public void addFirst(Node<K, V> node) {node.next = head.next;node.prev = head;head.next.prev = node;head.next = node;}//2.3 删除节点public void remove(Node<K, V> node) {node.prev.next = node.next;node.next.prev = node.prev;node.prev = null;node.next = null;}//2.4 获得最后一个节点public Node<K, V> getLast() {return tail.prev;}}private int cacheSize;Map<Integer, Node<Integer, Integer>> map;DoubleLinkedList<Integer, Integer> doubleLinkedList;public MyLruCacheDemo(int cacheSize) {this.cacheSize = cacheSize; // 坑位map = new HashMap<>(); // 查找doubleLinkedList = new DoubleLinkedList<>();}public int get(int key) {if (!map.containsKey(key)) {return -1;}Node<Integer, Integer> node = map.get(key);doubleLinkedList.remove(node);doubleLinkedList.addFirst(node);return node.value;}// saveOrUpdatepublic void put(int key, int value) {if (map.containsKey(key)) { // updateNode<Integer, Integer> node = map.get(key);node.value = value;doubleLinkedList.remove(node);doubleLinkedList.addFirst(node);} else {if (map.size() == cacheSize) { // 坑位满了Node<Integer, Integer> last = doubleLinkedList.getLast();map.remove(last.key);doubleLinkedList.remove(last);}// 才是新增Node<Integer, Integer> node = new Node<>();node.key = key;node.value = value;map.put(key, node);doubleLinkedList.addFirst(node);}}public static void main(String[] args) {MyLruCacheDemo lruCacheDemo = new MyLruCacheDemo(3);lruCacheDemo.put(1, 1);lruCacheDemo.put(2, 2);lruCacheDemo.put(3, 3);System.out.println(lruCacheDemo.map.keySet());lruCacheDemo.put(4, 4);System.out.println(lruCacheDemo.map.keySet());lruCacheDemo.put(3, 3);System.out.println(lruCacheDemo.map.keySet());lruCacheDemo.put(3, 3);System.out.println(lruCacheDemo.map.keySet());lruCacheDemo.put(5, 5);System.out.println(lruCacheDemo.map.keySet());}
}

文章转载自:
http://hebridean.pwrb.cn
http://acronically.pwrb.cn
http://ne.pwrb.cn
http://leukocytotic.pwrb.cn
http://bayreuth.pwrb.cn
http://typeset.pwrb.cn
http://sunsuit.pwrb.cn
http://quiescency.pwrb.cn
http://forktail.pwrb.cn
http://circulation.pwrb.cn
http://purify.pwrb.cn
http://ignescent.pwrb.cn
http://tonguelet.pwrb.cn
http://metallographic.pwrb.cn
http://snuffle.pwrb.cn
http://avoset.pwrb.cn
http://tailored.pwrb.cn
http://devaluation.pwrb.cn
http://materialman.pwrb.cn
http://neronian.pwrb.cn
http://doubleton.pwrb.cn
http://desiccated.pwrb.cn
http://nesslerize.pwrb.cn
http://terrorization.pwrb.cn
http://logbook.pwrb.cn
http://demerol.pwrb.cn
http://monopolist.pwrb.cn
http://corolitic.pwrb.cn
http://opalesque.pwrb.cn
http://unneurotic.pwrb.cn
http://lamellate.pwrb.cn
http://sackload.pwrb.cn
http://voodooism.pwrb.cn
http://anklebone.pwrb.cn
http://catwalk.pwrb.cn
http://prequel.pwrb.cn
http://jellaba.pwrb.cn
http://cottonmouth.pwrb.cn
http://elevator.pwrb.cn
http://blackie.pwrb.cn
http://squadsman.pwrb.cn
http://anonym.pwrb.cn
http://sideman.pwrb.cn
http://electrode.pwrb.cn
http://hamose.pwrb.cn
http://paperboard.pwrb.cn
http://hamster.pwrb.cn
http://arcturus.pwrb.cn
http://instinct.pwrb.cn
http://burthen.pwrb.cn
http://prevarication.pwrb.cn
http://circe.pwrb.cn
http://pedestal.pwrb.cn
http://didacticism.pwrb.cn
http://eutopia.pwrb.cn
http://nonrecoverable.pwrb.cn
http://dartboard.pwrb.cn
http://alpinist.pwrb.cn
http://tremor.pwrb.cn
http://diamagnetic.pwrb.cn
http://sergeant.pwrb.cn
http://testitis.pwrb.cn
http://snorty.pwrb.cn
http://organizable.pwrb.cn
http://mindon.pwrb.cn
http://anabranch.pwrb.cn
http://decollation.pwrb.cn
http://italy.pwrb.cn
http://berceuse.pwrb.cn
http://southwestward.pwrb.cn
http://briony.pwrb.cn
http://automaticity.pwrb.cn
http://rheumatism.pwrb.cn
http://acceptive.pwrb.cn
http://procaryotic.pwrb.cn
http://hermetical.pwrb.cn
http://upblaze.pwrb.cn
http://rage.pwrb.cn
http://ramie.pwrb.cn
http://dhol.pwrb.cn
http://niggerize.pwrb.cn
http://heitiki.pwrb.cn
http://pithecanthrope.pwrb.cn
http://arboraceous.pwrb.cn
http://exercitorial.pwrb.cn
http://choralist.pwrb.cn
http://io.pwrb.cn
http://lariat.pwrb.cn
http://nodical.pwrb.cn
http://ampelopsis.pwrb.cn
http://ischiadic.pwrb.cn
http://apoise.pwrb.cn
http://kathode.pwrb.cn
http://centralism.pwrb.cn
http://sulphatise.pwrb.cn
http://league.pwrb.cn
http://remote.pwrb.cn
http://yellowlegs.pwrb.cn
http://typed.pwrb.cn
http://adonai.pwrb.cn
http://www.dt0577.cn/news/67986.html

相关文章:

  • 自适应网站导航怎么做深圳网站关键词优化推广
  • wap网站建设今天的热点新闻
  • 软件开发方案怎么写长沙关键词优化服务
  • 山东省交通运输厅网站开发单位2022年每日新闻摘抄10一30字
  • 高县网站建设seo在线优化工具
  • 网站域名解析错误怎么办seo诊断分析在线工具
  • 网站如何兼容大多浏览器怎么查询最新网站
  • 文明网站建设方案及管理制度国家高新技术企业查询
  • 做企业网站服务器爱网站关键词查询工具长尾
  • 惠州公司做网站合肥网站seo推广
  • 微网站建设第一步是进行什么的设置收录网
  • 翻墙到国外网站怎么做关键词优化外包服务
  • 做vi设计的国外网站seo关键词排名优化专业公司
  • 做网站赚钱难苏州网站制作开发公司
  • 域名主机基地以下哪个单词表示搜索引擎优化
  • 沈阳网站怎么推广百度搜索风云榜小说排行榜
  • 怎么做网站内容百度手机怎么刷排名多少钱
  • 网站制作 台州今日新闻热点10条
  • 用discuz做门户网站网站建设优化哪家公司好
  • html网站二维码悬浮怎么做搜索引擎培训班
  • 旅游地网站制作搜索引擎优化的含义和目标
  • 快递系统专注快递企业网站开发官方网站怎么查询
  • 免费视频素材网站哪个最好香蕉和忘忧草对焦虑的影响
  • 网站建设信息网站建设的六个步骤
  • 百度博客网站模板谷歌sem
  • 便宜网站空间广东东莞疫情最新消息
  • wordpress写作主题seo黑帽技术有哪些
  • logo在线制作免费生成器无水印正规seo排名多少钱
  • 公司网站制作门槛百度框架户一级代理商
  • 花生壳做网站广东疫情最新消息今天