无法获取咖啡因缓存的统计信息(Spring5)

t5fffqht  于 2021-07-26  发布在  Java
关注(0)|答案(0)|浏览(245)

我陷入了一个(希望是)非常简单的问题。我在spring应用程序中添加了一个咖啡因缓存,这个缓存运行得很好。现在我尝试获取这个缓存的统计信息,但是找不到正确的方法。。。

import com.github.benmanes.caffeine.cache.Caffeine;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.caffeine.CaffeineCacheManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

@Configuration
@EnableCaching
public class CachingConfig {

    @Bean
    public CacheManager cacheManager() {
        CaffeineCacheManager cacheManager = new CaffeineCacheManager("bin");
        cacheManager.setCaffeine(Caffeine.newBuilder()
                .maximumSize(10000)
                .expireAfterWrite(1, TimeUnit.DAYS)
                .recordStats());
        return cacheManager;
    }

}

如何获取此缓存的统计信息?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题