Interface ExpirationAction

All Known Implementing Classes:
LoginFailureExpirationAction, RevokedTokenExpirationAction, SingleUseObjectExpirationAction
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ExpirationAction
A callback that removes expired entries from the database.

Implementations execute the actual deletion logic (e.g. a JPA query) and report how many rows were removed via the removeCount consumer. The framework calls this method inside a transaction, potentially multiple times in a loop to support batched deletions.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    removeExpired(KeycloakSession session, String realmId, int currentTime, int maxRemoval, IntConsumer removeCount)
    Removes expired entries from the database.
  • Method Details

    • removeExpired

      boolean removeExpired(KeycloakSession session, String realmId, int currentTime, int maxRemoval, IntConsumer removeCount)
      Removes expired entries from the database.

      This method is invoked inside a transaction. It should delete a batch of expired entries whose expiration time is at or before currentTime and report the number of removed rows via removeCount.

      Parameters:
      session - the current Keycloak session, valid for the duration of the enclosing transaction.
      realmId - the realm to clean up, or null for non-realm-aware expiration tasks.
      currentTime - the current time in seconds since epoch, used as the expiration threshold. This value is constant across all batches within a single task run.
      maxRemoval - the maximum number of entries to remove in this batch.
      removeCount - a consumer to report the number of entries removed in this batch.
      Returns:
      true if there are more expired entries to remove (the framework will call this method again in a new transaction); false if all expired entries have been removed.