当前位置:网站首页>Caffeine缓存增改查过期
Caffeine缓存增改查过期
2022-07-20 03:39:00 【学习微站】
Caffeine缓存增改查过期
1、引入pom
com.github.ben-manes.caffeine
caffeine
2.9.2
2、测试类
@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest(classes = ReportApplication.class)
public class LocalCacheTest {
@Test
public void test() throws InterruptedException {
Cache<Object, String> cache1 = Caffeine.newBuilder()
.expireAfterWrite(1, TimeUnit.SECONDS)
.maximumSize(1000)
.build();
String key = "test";
cache1.put(key, "Okok10000");
System.out.println(cache1.getIfPresent(key));
System.out.println(cache1.getIfPresent(key));
cache1.put(key, "hello0");
System.out.println(cache1.getIfPresent(key));
Thread.sleep(1000);
System.out.println(cache1.getIfPresent(key));
}
}
缓存----》内存 缓存过期时间和是否需要用缓存想好了再用
边栏推荐
- 亮点抢先看!2022开放原子全球开源峰会定于7月25-29日在北京举办
- Video 25-7 Chapter 2 VGg 26 Nin 27 goolenet
- 分享一个好玩的JS小游戏
- vscode setting
- [special for training course] Introduction to storage API
- Search insertion position of C language force deduction question 35. Classical Dichotomy
- DTOS帝拓思的3D引擎将取代游戏引擎巨兽,实现国产化替代
- RedHat 7 network service cannot start. The problem ("device does not see to be present, delaying initialization") is handled
- Responsive dream weaving template lock cylinder website
- [special for training courses] trustzone--tzc400 set safe memory
猜你喜欢
重新定义分析 - EventBridge 实时事件分析平台发布
AIOps 还是 APM,企业用户应如何作出选择?
scala Breaks.break()、Breaks.breakable()、控制抽象
redis分布式锁+线程池
[upload range 12-16] cut, picture horse
[upload range 1-11] basic level: characteristics, analysis and utilization
【无标题】
MySQL metabase & Account Management & Engine
5G时代到来,VR全景制作是值得创业的行业
分享一个好玩的JS小游戏
随机推荐
SQL Server 2008 R2 uninstall failed
MySQL transaction management
【Pytorch】Tensorboard用法:标量曲线图、直方图、模型结构图
DenseNet学习笔记(核心与resnet进行对比):
36-【go】Golang的IO流
Leetcode sword finger offer 32 - ii Print binary tree II from top to bottom
[special for training courses] trustzone--tzc400 set safe memory
Leetcode sword finger offer 11 Rotate the minimum number of the array
Leetcode sword finger offer 32 - I. print binary tree from top to bottom
How to create a plug-in for QML through cmake
How does the product manager arrange the time after work?
正则表达式教程笔记
[pygame Learning notes] 8. Elfe.
U.S. lawmakers advocate cracking down on encrypted mining, ringing the alarm of encryption? Only by reducing the carbon footprint can we achieve real value
Interpretation of new features | the restriction of MySQL 8.0 on gtid is lifted
LeetCode Algorithm 138. 复制带随机指针的链表
The third national finals of the University of Hong Kong Space China business school and enterprise research institute innovation and entrepreneurship competition came to a successful conclusion
MySQL - partition column (horizontal partition vertical partition)
Protocol details of network principles
推荐一个截图工具-Snipaste