@Override
    public long deleteSingleTicket(final Ticket ticket) {
        val redisKeyGenerator = redisKeyGeneratorFactory.getRedisKeyGenerator(ticket.getPrefix()).orElseThrow();
        val redisTicketsKey = redisKeyGenerator.forPrefixAndId(ticket.getPrefix(), digestIdentifier(ticket.getId()));
        val count = Stream.of(redisTicketsKey)
            .mapToInt(id -> BooleanUtils.toBoolean(casRedisTemplates.getTicketsRedisTemplate().delete(id)) ? 1 : 0)
            .sum();

        if (ticket instanceof TicketGrantingTicket) {
            redisKeyGeneratorFactory.getRedisKeyGenerator(Principal.class.getName())
                .ifPresent(principalGenerator -> {
                    val userId = digestIdentifier(getPrincipalIdFrom(ticket));
                    if (StringUtils.isNotBlank(userId)) {
                        val digestedId = digestIdentifier(ticket.getId());
                        val redisPrincipalKey = principalGenerator.forId(userId);
                        val ops = casRedisTemplates.getSessionsRedisTemplate().boundZSetOps(redisPrincipalKey);
                        ops.remove(digestedId);
                    }
                });
        }

        ticketCache.ifAvailable(cache -> cache.invalidate(redisKeyGenerator.rawKey(redisTicketsKey)));
        messagePublisher.ifAvailable(publisher -> publisher.delete(ticket));
        return count;
    }
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