如何获取 Spring-cache 中缓存的大小?

Posted

技术标签:

【中文标题】如何获取 Spring-cache 中缓存的大小?【英文标题】:How can I get the size of the cache in Spring-cache? 【发布时间】:2020-08-21 23:47:43 【问题描述】:

如何知道 spring-cache 中缓存的当前缓存大小? 我想在缓存大小达到最大值时记录。我找不到这样做的功能。我怎么知道?

【问题讨论】:

【参考方案1】:

Spring 的缓存抽象不处理底层细节。

你需要使用不同的缓存实现,你可以从这里看到一堆例子https://docs.spring.io/spring-boot/docs/2.1.6.RELEASE/reference/html/boot-features-caching.html#boot-features-caching-provider-simple

【讨论】:

目前有没有获取缓存大小的实现示例? 不幸的是,我以前从未尝试过,但是从那个 URL 实现示例存在。您可以通过谷歌搜索其中之一来找到更多详细信息

以上是关于如何获取 Spring-cache 中缓存的大小?的主要内容,如果未能解决你的问题,请参考以下文章

Spring-Cache缓存技术的使用

20springcloud如何使用spring-cache

20springcloud如何使用spring-cache

20springcloud如何使用spring-cache

spring-cache

Spring-Cache手动清缓存