How to empty Guava cache every 30 seconds while sending it to another method?
问题 I am populating my guava cache from multiple threads by calling add method. Now from the background thread which runs every 30 seconds, I want to send whatever is there in the cache to sendToDB method atomically? Below is my code: public class Example { private final ScheduledExecutorService executorService = Executors .newSingleThreadScheduledExecutor(); private final Cache<Integer, List<Process>> cache = CacheBuilder.newBuilder().maximumSize(100000) .removalListener(RemovalListeners