我遇到了一个(希望如此)非常简单的问题。我在 Spring 应用程序中添加了一个 Caffeine 缓存,这个缓存运行良好。 现在我尝试获取此缓存的统计信息,但找不到获取正确方法的方法...
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;
}
}
如何获取此缓存的统计信息?