当前位置:网站首页>[high concurrency] interviewer
[high concurrency] interviewer
2022-07-27 06:00:00 【m0_ sixty-seven million five hundred and ninety-five thousand n】
Use Java Heap memory to store objects . The advantage of using heap caching is that there is no serialization / Deserialization , Is the fastest cache . The disadvantages are obvious , When the amount of cached data is large ,GC( Garbage collection ) The pause time will be longer , Storage capacity is limited by the size of heap space . Generally through soft reference / Weak references are used to store cached objects . That is, when the heap memory is low , This part of memory can be forcibly reclaimed to free up heap memory space . Generally, heap cache is used to store hot data . have access to Guava Cache、Ehcache 3.x、 MapDB Realization .
[](() Out of heap memory
That is, the cached data is stored in off heap memory , Can reduce the GC Pause time ( Move heap objects out of the heap ,GC Fewer objects are scanned and moved ), Can support more cache space ( Only limited by machine memory size , Not affected by heap space ). however , Serialization is required when reading data / Deserialization . therefore , It will be much slower than heap cache . have access to Ehcache 3.x、 MapDB Realization .
[](() Disk caching
That is, cache data is stored on disk , stay JVM The data still exists when restarting , And heaps / Out of heap cache data will be lost , Need to reload . have access to Ehcache 3.x、MapDB Realization .
[](() Distributed cache
Distributed caching can use ehcache-clustered( coordination Terracotta server) Realization Java Inter process distributed cache . You can also use Memcached、Redis Realization .
When using distributed caching , There are two modes as follows :
standalone mode : Store the hottest data to the heap cache , Relatively hot data to the off heap cache , Not hot data to disk cache .
Cluster pattern : Store the hottest data to the heap cache , Relatively hot data to external cache , Full data to distributed cache .
[](() Cache recovery policy
------------------------------ 《 A big factory Java Analysis of interview questions + Back end development learning notes + The latest architecture explanation video + Practical project source code handout 》 Free open source Prestige search official account 【 Advanced programming 】 ----------------------------------
The cache recycling strategy generally includes : Space based recycling strategy 、 Based on capacity ( Space ) Recycling strategy for 、 Time based recycling strategy and object reference based recycling strategy .

[](() Based on space
Storage space is set based on the cache , If set to 10MB, When the maximum storage space is reached , Remove data according to certain policies .
[](() Based on capacity
The maximum size of the cache is set based on the capacity , When the cached entry exceeds the maximum size , Remove old data according to certain policies .
[](() Based on time
TTL(Time To Live): Survival period , That is, a period of time from creation to expiration of cached data ( Whether or not visited during this time period , All cached data will expire ).
TTI(Time To Idle): Idle period , That is, the time to remove the cache after the cached data has not been accessed .
[](() Based on object reference
Soft citation : If an object is a soft reference , Then when JVM When the heap is low on memory , The garbage collector can recycle these objects . Soft references are suitable for caching , So as to be JVM When the heap is low on memory , You can recycle these objects to make room for strongly referenced objects , To avoid OOM.
Weak reference : When the garbage collector reclaims memory , If weak references are found , Then recycle it immediately . Relative to soft reference , Weak references have a shorter life cycle .
Be careful : Only when no other strong reference object references weak references / When soft referencing objects , The reference is recycled only when garbage collection . That is, if there is an object ( It's not a weak quote / Soft reference objects ) A weak quotation was quoted / Soft reference objects , Then the weak reference will not be recycled during garbage collection / Soft reference objects .
边栏推荐
- Numpy basic learning
- 6. Dimension transformation and broadcasting
- Public opinion & spatio-temporal analysis of infectious diseases literature reading notes
- 小技巧-彻底删除U盘中的文件
- 常用adb命令汇总 性能优化
- 神经网络参数初始化
- Gbase 8C - SQL reference 5 full text search
- 李宏毅 2020 深度学习与人类语言处理 DLHLP-Coreference Resolution-p21
- Day 9. Graduate survey: A love–hurt relationship
- GBASE 8C——SQL参考6 sql语法(6)
猜你喜欢
随机推荐
RK3288板卡HDMI显示uboot和kernel的logo图片
Unittest套件与运行器
SoK: The Faults in our ASRs: An Overview of Attacks against Automatic Speech Recognition (题目过长)阅读笔记
7. Merger and division
基于深度神经网络的社交媒体用户级心理压力检测
GBASE 8C——SQL参考6 sql语法(15)
数字图像处理 第一章 绪论
Day14. 用可解释机器学习方法鉴别肠结核和克罗恩病
GBASE 8C——SQL参考6 sql语法(1)
Day10. Work organization and mental health problems in PhD students
9. High order operation
Day 4.Social Data Sentiment Analysis: Detection of Adolescent Depression Signals
12.优化问题实战
4. Tensor data type and creation tensor
西瓜书学习第五章---神经网络
go通过channel获取goroutine的处理结果
Uboot中支持lcd和hdmi显示不同的logo图片
pytorch的多GPU训练的两种方式
Day 9. Graduate survey: A love–hurt relationship
9.高阶操作



![[MVC Architecture] MVC model](/img/71/e10da490d5f0098c64b33e77d158e7.png)

![[MySQL learning] 8](/img/25/84d5acbdd8aba3455ab8e3eb17dfa8.png)



