我正在使用JCache API在应用程序中配置缓存,该应用程序在Ehcache 3中使用弹簧缓存。
cacheManager.createCache("users", new MutableConfiguration<String, User>()
.setStoreByValue(false)
.setManagementEnabled(true)
.setStatisticsEnabled(true)
.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(Duration.TEN_MINUTES)));
Run Code Online (Sandbox Code Playgroud)
如何将缓存大小限制为50个条目?通过Ehcache XML配置很容易做到这一点,但是如果有一种使用JCache config API进行控制的方法,我宁愿使用它。