当前位置:网站首页>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
边栏推荐
- [problem solving] 'ASCII' codec can't encode characters in position XX XX: ordinal not in range (128)
- Imitation Baidu map realizes the three buttons to switch the map mode by automatically shrinking the bottom
- Leetcode 994, rotten orange
- An error is reported in the initialization metadata of the dolphin scheduler -- it turns out that there is a special symbol in the password. "$“
- bounding box iou
- Use the rolling division method to find the maximum common divisor of two numbers
- Markdown < a > tag new page open link
- After route link navigation, the sub page does not display the navigation style problem
- selenium. common. exceptions. WebDriverException: Message: ‘chromedriver‘ executable needs to be in PAT
- Sqoop imports data from Mysql to HDFS using lzop compression format and reports NullPointerException
猜你喜欢
Development of Matlab GUI bridge auxiliary Designer (functional introduction)
Numpy Index & slice & iteration
BMP JPEG picture to vector image contourtrace
[stack and queue topics] - sliding window
Vscode download speed up
Es error: request contains unrecognized parameter [ignore_throttled]
上海回应“面粉官网是非法网站”:疏于运维被“黑”,警方已立案
Mathematical modeling column | Part 5: MATLAB optimization model solving method (Part I): Standard Model
SQL Server Connectors By Thread Pool | DTSQLServerTP plugin instructions
LeetCode 994、腐烂的橘子
随机推荐
Actual measurement of automatic ticket grabbing script of barley network based on selenium (the first part of the new year)
A useless confession artifact
Plato Farm元宇宙IEO上线四大,链上交易颇高
On BIM data redundancy theory
Plato farm is one of the four largest online IEOS in metauniverse, and the transaction on the chain is quite high
LeetCode 20、有效的括号
SQL gets the latest record of the data table
BMP JPEG 图片转换为矢量图像 ContourTrace
Development of Matlab GUI bridge auxiliary Designer (functional introduction)
Parsing methods of JSON data in C - jar and jobobject: error reading jar from jsonreader Current JsonReader item
2022DASCTF Apr X FATE 防疫挑战赛 CRYPTO easy_real
Markdown < a > tag new page open link
Historical track data reading of Holux m1200-e Bluetooth GPS track recorder
[latex] 5 how to quickly write out the latex formula corresponding to the formula
Use the rolling division method to find the maximum common divisor of two numbers
Tensorflow 2 basic operation dictionary
打新债中签以后怎么办,网上开户安全吗
LeetCode 709、转换成小写字母
WordPress plug-in: WP CHINA Yes solution to slow domestic access to the official website
SQL Server connectors by thread pool 𞓜 instructions for dtsqlservertp plug-in