当前位置:网站首页>[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 .
边栏推荐
- 【并发编程系列9】阻塞队列之PriorityBlockingQueue,DelayQueue原理分析
- 3. Classification problems - initial experience of handwritten digit recognition
- Brief analysis of application process creation process of activity
- 7. Merger and division
- 13.逻辑回归
- 1. Introduction to pytorch
- 15.GPU加速、minist测试实战和visdom可视化
- golang中slice切片使用的误区
- Activity之应用进程创建流程简析
- GBASE 8C——SQL参考6 sql语法(2)
猜你喜欢
随机推荐
12. Optimization problem practice
【MVC架构】MVC模型
8.数学运算与属性统计
mysql优化sql相关(持续补充)
Digital image processing Chapter 2 fundamentals of digital image
Gbase 8C - SQL reference 6 SQL syntax (3)
Inno setup package jar + H5 + MySQL + redis into exe
2020年PHP中级面试知识点及答案
13.逻辑回归
数字图像处理——第六章 彩色图像处理
9. High order operation
andorid检测GPU呈现速度和过度绘制
8. Mathematical operation and attribute statistics
18. Convolutional neural network
[MySQL learning] 8
一张照片攻破人脸识别系统:能点头摇头张嘴,网友
Gbase 8C - SQL reference 6 SQL syntax (7)
pytorch的多GPU训练的两种方式
Day 4.Social Data Sentiment Analysis: Detection of Adolescent Depression Signals
维度问题以及等高线







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