当前位置:网站首页>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
边栏推荐
- 16MySQL之DCL 中 COMMIT和ROllBACK
- [PTA] l1-002 printing hourglass
- 内网渗透之DOS命令
- 16MySQL之DCL 中 COMMIT和ROllBACK
- 6-5 string - 2 String copy (assignment) (10 points) the C language standard function library includes the strcpy function for string copy (assignment). As an exercise, we write a function with the sam
- 【PTA】整除光棍
- Research on open source OCR engine
- JDBC tool class jdbcconutil gets the connection to the database
- selenium. common. exceptions. WebDriverException: Message: ‘chromedriver‘ executable needs to be in PAT
- The market share of the financial industry exceeds 50%, and zdns has built a solid foundation for the financial technology network
猜你喜欢
Identification of bolt points in aerial photography based on perception
高薪程序员&面试题精讲系列91之Limit 20000加载很慢怎么解决?如何定位慢SQL?
SQL Server Connectors By Thread Pool | DTSQLServerTP plugin instructions
【PTA】整除光棍
Don't bother tensorflow learning notes (10-12) -- Constructing a simple neural network and its visualization
C migration project record: modify namespace and folder name
Wave field Dao new species end up, how does usdd break the situation and stabilize the currency market?
Actual measurement of automatic ticket grabbing script of barley network based on selenium (the first part of the new year)
Commit and ROLLBACK in DCL of 16mysql
Click an EL checkbox to select all questions
随机推荐
Latest investigation and progress of building intelligence based on sati
LeetCode 232、用栈实现队列
Shanghai a répondu que « le site officiel de la farine est illégal »: l'exploitation et l'entretien négligents ont été « noirs » et la police a déposé une plainte
BMP JPEG 图片转换为矢量图像 ContourTrace
bounding box iou
Building the tide, building the foundation and winning the future -- the successful holding of zdns Partner Conference
I JS deep copy and shallow copy
Leetcode 1351. Negative numbers in statistical ordered matrices
Change the material of unity model as a whole
How do BIM swindlers cheat? (turn)
Alicloud: could not connect to SMTP host: SMTP 163.com, port: 25
Don't bother tensorflow learning notes (10-12) -- Constructing a simple neural network and its visualization
Actual measurement of automatic ticket grabbing script of barley network based on selenium (the first part of the new year)
Solve the Chinese garbled code of URL in JS - decoding
How does onlyoffice solve no route to host
【PTA】L2-011 玩转二叉树
Plato farm is one of the four largest online IEOS in metauniverse, and the transaction on the chain is quite high
Numpy Index & slice & iteration
[stack and queue topics] - sliding window
[PTA] l1-002 printing hourglass