当前位置:网站首页>Preliminary understanding of cache elimination algorithm (LRU and LFU)
Preliminary understanding of cache elimination algorithm (LRU and LFU)
2022-04-23 20:29:00 【Game programming】
API: namely Application Programming Interface ( Application programming interface ). The operating system will encapsulate some complex underlying operations into simple functions , The programmer only needs to call the corresponding function to realize the low-level detailed operation .(c There is printf、scanf、fopen, stay c++ in API Including functions and classes )
Cache elimination algorithm : Memory capacity is limited , When the data you want to cache exceeds the capacity , You have to delete some data , What data is deleted at this time , What data is retained , Namely LRU Algorithm and LFU Algorithm ,FU What is emphasized is that Number of visits , and LRU What is emphasized is that Access time .
LRU: namely Least Recently Used ( Least recently used algorithm ). Data that has not been used for a long time is regarded as useless data , When the cache is full , Priority will be given to deleting these identified data .
LRU In order to achieve the minimum time complexity of storing and obtaining key value pairs , Use Hash list To realize the core of the algorithm , Hash table storage key, Every key Mapping key value pairs in a two-way linked list , In order to achieve the purpose of fast searching the linked list key( Hash table search time complexity O(1)).

LFU: namely Least Frequently Used ( The least frequently used algorithm ). It is also the least likely that the data accessed the least times in a certain period will be accessed in the future . When the cache is full , Priority will be given to deleting these identified data .
LFU In order to select and eliminate according to frequency , So... Is adopted Double hash table As the core algorithm , First hash table fre_table, Its key Is the frequency of visits , Its value It's a two-way list , Each node of the bidirectional linked list contains three elements :key,value, as well as count. The second hash table key_table, Its key That is, the of the two-way linked list key,value Is a pointer to the corresponding position in the linked list .

( The following supplementary code part )
author : Easy to wind and dust
Game programming ️, A game development favorite ~
If the picture is not displayed for a long time , Please use Chrome Kernel browser .
版权声明
本文为[Game programming]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204232027530682.html
边栏推荐
- Error reported by Azkaban: Azkaban jobExecutor. utils. process. ProcessFailureException: Process exited with code 127
- 堡垒机、跳板机JumpServer的搭建,以及使用,图文详细
- Linux64Bit下安装MySQL5.6-不能修改root密码
- Experience of mathematical modeling in 18 year research competition
- Vscode download speed up
- Some basic knowledge of devexpress report development
- SQL Server Connectors By Thread Pool | DTSQLServerTP plugin instructions
- Tensorflow 2 basic operation dictionary
- Leetcode 74. Search two-dimensional matrix
- ABAQUS script email auto notification
猜你喜欢
【PTA】L1-002 打印沙漏
Servlet learning notes
Leetcode 542, 01 matrix
Tensorflow 2 basic operation dictionary
LeetCode 116. Populate the next right node pointer for each node
Zdns was invited to attend the annual conference of Tencent cloud basic resources and share the 2020 domain name industry development report
Es keyword sorting error reason = fielddata is disabled on text fields by default Set fielddata = true on keyword in order
Azkaban recompile, solve: could not connect to SMTP host: SMTP 163.com, port: 465 [January 10, 2022]
Leetcode 994, rotten orange
Some basic configurations in interlij idea
随机推荐
上海回应“面粉官网是非法网站”:疏于运维被“黑”,警方已立案
The ODB model calculates the data and outputs it to excel
Devaxpress report replay: complete the drawing of conventional two-dimensional report + histogram + pie chart
Change the material of unity model as a whole
Devexpress 14.1 installation record
Tensorflow 2 basic operation dictionary
JDBC database addition, deletion, query and modification tool class
I JS deep copy and shallow copy
Imitation Baidu map realizes the three buttons to switch the map mode by automatically shrinking the bottom
LeetCode 20、有效的括号
How does onlyoffice solve no route to host
LeetCode 994、腐烂的橘子
Customize timeline component styles
高薪程序员&面试题精讲系列91之Limit 20000加载很慢怎么解决?如何定位慢SQL?
Building the tide, building the foundation and winning the future -- the successful holding of zdns Partner Conference
SQL: query duplicate data and delete duplicate data
RT-1052学习笔记 - GPIO架构分析
Leetcode 20. Valid parentheses
JDBC tool class jdbcfiledateutil uploads files and date format conversion, including the latest, simplest and easiest way to upload single files and multiple files
【PTA】整除光棍