当前位置:网站首页>LeetCode 146. LRU cache
LeetCode 146. LRU cache
2022-06-12 22:56:00 【Go to bed early and be healthy HH】
Topic link :https://leetcode-cn.com/problems/lru-cache/
cache (Cache) It is a technology to improve data reading performance , In hardware design 、 It is widely used in software development , For example, the common CPU cache 、 Database cache 、 Browser caching and so on .

The size of the cache is limited . When the cache is full , What data should be cleaned out , What data should be kept , This requires a cache obsolescence strategy .
FIFO(First In First Out), First in, first out strategy
thought : If a data is the first to enter , So it can be thought that in the future it is very unlikely to be visited . When the space is full , The data that enters first will be eliminated first .
LFU(Least Frequently Used), Least recently used strategy
thought : If data is rarely accessed in a recent period of time , So it can be thought that it is unlikely to be visited in the future . therefore , When the space is full , The least frequently accessed data is the first to be eliminated .
LRU(Least Recently Used), The last time you haven't used a strategy recently
thought : If a data has not been accessed in a recent period of time , So it can be thought that it is unlikely to be visited in the future . therefore , When the space is full , The data that has not been accessed for the longest time is eliminated first .
Intuitive ideas : Store the most recently used elements near the top of the cache , When a new entry is accessed ,LRU Put it at the top of the cache . When the cache is full , Entries accessed earlier will be removed from the bottom of the cache .
Hashtable + Array

Hashtable + Single chain list


Hashtable + Double linked list

边栏推荐
- China's elastic belt market trend report, technical dynamic innovation and market forecast
- 認識的幾比特清華同學都離職了……
- 【LeetCode】33. 搜索旋转排序数组
- Mysql concat_ WS, concat function use
- Plusieurs camarades de classe de Tsinghua sont partis...
- Go时间格式化 赋值
- The "fourteenth five year plan" development plan and panoramic strategic analysis report of China's information and innovation industry 2022 ~ 2028
- 【LeetCode】103. 二叉树的锯齿形层序遍历
- USB mechanical keyboard changed to Bluetooth Keyboard
- flutter系列之:flutter中常用的GridView layout详解
猜你喜欢

(downloadable) Research Report on the development and utilization of government data (2021), a glimpse of the development of Government Office

JVM Basics - > What are the thread shared areas in the JVM

The development trend of digital collections!

深度学习-神经网络:卷积的实现方法【直接法(精度没损失)、GEMM(矩阵乘法,精度没损失)、FFT(傅里叶变换,精度有损失)、Winograd(精度有损失)】
![[Part VI] source code analysis and application details of countdownlatch [key]](/img/6e/085e257c938a8c7b88c12c36df83e1.jpg)
[Part VI] source code analysis and application details of countdownlatch [key]

iShot

The annual salary of 500000 is one line, and the annual salary of 1million is another line

The programmer dedicated to promoting VIM has left. Father of vim: I will dedicate version 9.0 to him

Mysql concat_ws、concat函数使用

管线中的坐标变换
随机推荐
JVM foundation > GC generation: minorgc majorgc fullgc mixed GC
ShardingSphere-proxy-5.0.0部署之分表实现(一)
Use js to listen for Keydown event
China's elastic belt market trend report, technical dynamic innovation and market forecast
Mysql concat_ws、concat函数使用
Mysql concat_ WS, concat function use
Qt Quick 3D学习:鼠标拾取物体
細數攻防演練中十大關鍵防守點
JVM foundation - > three ⾊ mark
年薪50万是一条线,年薪100万又是一条线…...
基于51单片机的酒精检测仪
四元数简介
Inventory of CV neural network models from 2021 to 2022
JVM foundation - > What garbage collectors does the JVM have?
Use of map() function in JS
PHP deletes data of the same item in a two-dimensional array
Zhengzhou University of light industry -- development and sharing of harmonyos pet health system
認識的幾比特清華同學都離職了……
Coordinate transformation in pipelines
A 42 year old senior executive of a large factory reminds people aged 30-39 that these six habits that make you stronger should be developed as soon as possible