@Override
    public Ticket addSingleTicket(final Ticket ticket) {
        try {
            LOGGER.debug("Adding ticket [{}]", ticket.getId());
            val document = buildTicketAsDocument(ticket);
            val metadata = ticketCatalog.find(ticket);
            if (metadata == null) {
                LOGGER.error("Could not locate ticket definition in the catalog for ticket [{}]", ticket.getId());
            } else {
                LOGGER.trace("Located ticket definition [{}] in the ticket catalog", metadata);
                val collectionName = getTicketCollectionInstanceByMetadata(metadata);
                LOGGER.trace("Found collection [{}] linked to ticket [{}]", collectionName, metadata);
                mongoTemplate.insert(document, collectionName);
                LOGGER.debug("Added ticket [{}]", ticket.getId());
            }
        } catch (final Throwable e) {
            LOGGER.error("Failed adding [{}]", ticket);
            LoggingUtils.error(LOGGER, e);
        }
        return ticket;
    }
Calculate the time at which the ticket is eligible for automated deletion by MongoDb.
Makes the assumption that the CAS server date and the Mongo server date are in sync.
support/cas-server-support-mongo-ticket-registry/src/main/java/org/apereo/cas/ticket/registry/MongoDbTicketRegistry.java