private void addOrUpdateTicket(final Ticket ticket) {
        val digestedId = digestIdentifier(ticket.getId());
        val redisKeyGenerator = redisKeyGeneratorFactory.getRedisKeyGenerator(ticket.getPrefix()).orElseThrow();
        val redisKeyPattern = redisKeyGenerator.forPrefixAndId(ticket.getPrefix(), digestedId);

        val timeout = RedisKeyGenerator.getTicketExpirationInSeconds(ticket);
        val ticketDocument = buildTicketAsDocument(ticket);

        val valueOps = casRedisTemplates.getTicketsRedisTemplate().boundValueOps(redisKeyPattern);
        valueOps.set(ticketDocument, timeout, TimeUnit.SECONDS);

        val keyspace = redisKeyGenerator.getKeyspace();
        val redisDataItem = new RedisData();
        redisKeyValueAdapter.getConverter().write(ticketDocument, redisDataItem);
        redisDataItem.setKeyspace(keyspace);

        redisKeyValueAdapter.put(ticketDocument.ticketId(), redisDataItem, keyspace);
        configureTicketExpirationInstant(ticket, redisKeyPattern);
        ticketCache.ifAvailable(cache -> cache.put(digestedId, ticket));

        redisKeyGeneratorFactory.getRedisKeyGenerator(Principal.class.getName())
            .ifPresent(generator -> trackAuthenticationPrincipal(ticket));
    }
Key-value ticket registry implementation that stores tickets in redis.

@author Misagh Moayyed
@author Jerome Leleu
@since 5.1.0
support/cas-server-support-redis-ticket-registry/src/main/java/org/apereo/cas/ticket/registry/RedisTicketRegistry.java