当前位置:网站首页>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
边栏推荐
- 堡垒机、跳板机JumpServer的搭建,以及使用,图文详细
- LeetCode 1351、统计有序矩阵中的负数
- Research on open source OCR engine
- BMP JPEG picture to vector image contourtrace
- PCA based geometric feature calculation of PCL point cloud processing (52)
- LeetCode 1346、检查整数及其两倍数是否存在
- bounding box iou
- Numpy - creation of data type and array
- Mysql database backup scheme
- Parsing methods of JSON data in C - jar and jobobject: error reading jar from jsonreader Current JsonReader item
猜你喜欢

Commit and ROLLBACK in DCL of 16mysql

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

. Ren -- the intimate artifact in the field of vertical Recruitment!

堡垒机、跳板机JumpServer的搭建,以及使用,图文详细

go-zero框架数据库方面避坑指南

Identification of bolt points in aerial photography based on perception

DOS command of Intranet penetration

Numpy mathematical function & logical function

上海回應“面粉官網是非法網站”:疏於運維被“黑”,警方已立案

DNS cloud school | quickly locate DNS resolution exceptions and keep these four DNS status codes in mind
随机推荐
Wave field Dao new species end up, how does usdd break the situation and stabilize the currency market?
JDBC tool class jdbcconutil gets the connection to the database
[PTA] get rid of singles
Implementation of mypromise
Leetcode 20. Valid parentheses
Common form verification
Analysis of the relationship between generalized Bim and CAD under the current background
Historical track data reading of Holux m1200-e Bluetooth GPS track recorder
Cadence OrCAD capture batch change component packaging function introduction graphic tutorial and video demonstration
A useless confession artifact
Leetcode 232, queue with stack
Error reported by Azkaban: Azkaban jobExecutor. utils. process. ProcessFailureException: Process exited with code 127
Confusion about thread blocking after calling the read () method of wrapper flow
Why does ES6 need to introduce map when JS already has object type
Plato Farm元宇宙IEO上线四大,链上交易颇高
Solution to PowerDesigner's failure to connect to MySQL in x64 system
Handwritten Google's first generation distributed computing framework MapReduce
Leetcode 994, rotten orange
缓存淘汰算法初步认识(LRU和LFU)
The construction and use of Fortress machine and springboard machine jumpserver are detailed in pictures and texts