在此的CacheManager当时间限制与getTimeToLive(超过)ehCache缓存是否有任何自动刷新选项?没有任何调度程序的工作?
private void setCacheInstance() {
cacheManager
.createCache("rateDataCached", CacheConfigurationBuilder
.newCacheConfigurationBuilder(
Integer.class, PostageServicesResultHolder.class,
ResourcePoolsBuilder.heap(100))
.withExpiry(Expirations.timeToLiveExpiration(Duration.of(getTimeToLive(), TimeUnit.MINUTES))).build());
}
private long getTimeToLive() {
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("HH.mm");
Float currentTime = Float.parseFloat(sdf.format(cal.getTime()));
return (long) ((24.00-currentTime) * 60);
}
@ Anant666是我们可以尝试,但在我的情况下,我必须清除缓存而不使用任何作业或调度程序。 – SGG