@Override
    public int cleanTicket(final Ticket ticket) {
        return lockRepository.execute(ticket.getId(), () -> {
            val clientInfo = ClientInfoHolder.getClientInfo();
            if (ticket instanceof final TicketGrantingTicket tgt) {
                applicationContext.publishEvent(new CasRequestSingleLogoutEvent(this, tgt, clientInfo));
            }

            try {
                LOGGER.debug("Cleaning up expired ticket [{}]", ticket.getId());
                val nb = ticketRegistry.deleteTicket(ticket);
                if (ticket instanceof final TicketGrantingTicket tgt) {
                    applicationContext.publishEvent(new CasTicketGrantingTicketDestroyedEvent(this, tgt, clientInfo));
                }
                return nb;
            } catch (final Throwable e) {
                LoggingUtils.error(LOGGER, e);
                return 0;
            }
        }).orElse(0);
    }
This is {@link DefaultTicketRegistryCleaner}.

@author Misagh Moayyed
@since 5.0.0
core/cas-server-core-tickets-api/src/main/java/org/apereo/cas/ticket/registry/DefaultTicketRegistryCleaner.java