当前位置:网站首页>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
边栏推荐
- [graph theory brush question-5] Li Kou 1971 Find out if there is a path in the graph
- Alicloud: could not connect to SMTP host: SMTP 163.com, port: 25
- Experience of mathematical modeling in 18 year research competition
- Leetcode 994, rotten orange
- [graph theory brush question-4] force deduction 778 Swimming in a rising pool
- After route link navigation, the sub page does not display the navigation style problem
- Sqoop imports data from Mysql to HDFS using lzop compression format and reports NullPointerException
- Thirty What are VM and VC?
- Installation and use of NVM
- Leetcode 542, 01 matrix
猜你喜欢

A useless confession artifact

缓存淘汰算法初步认识(LRU和LFU)

Sqoop imports tinyint type fields to boolean type

Commit and rollback in DCL of 16 MySQL

Don't bother tensorflow learning notes (10-12) -- Constructing a simple neural network and its visualization

SQL Server Connectors By Thread Pool | DTSQLServerTP plugin instructions

Solution: NPM err! code ELIFECYCLE npm ERR! errno 1

Servlet learning notes

2022dasctf APR x fat epidemic prevention challenge crypto easy_ real

The construction and use of Fortress machine and springboard machine jumpserver are detailed in pictures and texts
随机推荐
SQL gets the latest record of the data table
Livego + ffmpeg + RTMP + flvjs to realize live video
论文写作 19: 会议论文与期刊论文的区别
堡垒机、跳板机JumpServer的搭建,以及使用,图文详细
RT-1052学习笔记 - GPIO架构分析
LeetCode 232、用栈实现队列
The construction and use of Fortress machine and springboard machine jumpserver are detailed in pictures and texts
Implementation of mypromise
JDBC tool class jdbcconutil gets the connection to the database
2022dasctf APR x fat epidemic prevention challenge crypto easy_ real
Numpy sort search count set
Leetcode 74. Search two-dimensional matrix
打新债中签以后怎么办,网上开户安全吗
BMP JPEG 图片转换为矢量图像 ContourTrace
【PTA】整除光棍
Commit and ROLLBACK in DCL of 16mysql
Es keyword sorting error reason = fielddata is disabled on text fields by default Set fielddata = true on keyword in order
PIP installation package reports an error. Could not find a version that satisfies the requirement pymysql (from versions: none)
黑客的入侵方式你知道几种?
Analysis of the relationship between generalized Bim and CAD under the current background