Module io.github.bucket4j.core
Interface ExpiredEntriesCleaner
-
public interface ExpiredEntriesCleanerInterface used by particularProxyManagerimplementations to indicate that they support the manual(triggered by user) removing of expired bucket entries.Typically, this interface is implemented by RDBMS backed proxy-managers where underlying DBMS is not support automatically expiration. And wise versa, this interface never implemented by Redis/JCache integrations, because for such technologies expiration is supported out-of-the box by underlying technology.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description intremoveExpired(int batchSize)Tries to remove expired bucket entries and put all removed keys to the returned collection.
-
-
-
Method Detail
-
removeExpired
int removeExpired(int batchSize)
Tries to remove expired bucket entries and put all removed keys to the returned collection. It is guaranteed that on call ofremoveExpireddoes not remove more thanbatchSizebuckets at once, it also means that returned result always less than or equal tobatchSize, so caller needs to analyze the size of returned collection and callremoveExpiredagain if needed.Example of usage:
{@code private static final int MAX_TO_REMOVE_IN_ONE_TRANSACTION = 1_000; private static final int THRESHOLD_TO_CONTINUE_REMOVING = 50; // once per day at 4:30 morning- Parameters:
batchSize- specifies how many expired buckets can be deleted in single transaction.- Returns:
- count of removed keys
-
-