Interface ExpiredEntriesCleaner


  • public interface ExpiredEntriesCleaner
    Interface used by particular ProxyManager implementations 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
      int removeExpired​(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 of removeExpired does not remove more than batchSize buckets at once, it also means that returned result always less than or equal to batchSize, so caller needs to analyze the size of returned collection and call removeExpired again 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