I am using Google Guava library for caching. For automatic cache refresh we can do as follows:
cache = CacheBuilder.newBuilder()
JAVA 8 version with parallel stream:
Executors .newSingleThreadScheduledExecutor() .scheduleWithFixedDelay(() -> configurationCache .asMap() .keySet() .parallelStream() .forEach((key) -> configurationCache.refresh(key)), 0, 1, TimeUnit.SECONDS);