public static RedisConnectionFactory newRedisConnectionFactory(final BaseRedisProperties redis,
                                                                   final boolean initialize,
                                                                   final CasSSLContext casSslContext) throws Exception {
        var factory = (LettuceConnectionFactory) null;
        if (redis.getSentinel() != null && StringUtils.hasText(redis.getSentinel().getMaster())) {
            factory = new LettuceConnectionFactory(getSentinelConfig(redis), getRedisPoolClientConfig(redis, casSslContext));
        } else if (redis.getCluster() != null && !redis.getCluster().getNodes().isEmpty()) {
            factory = new LettuceConnectionFactory(getClusterConfig(redis), getRedisPoolClientConfig(redis, casSslContext));
        } else {
            factory = new LettuceConnectionFactory(getStandaloneConfig(redis), getRedisPoolClientConfig(redis, casSslContext));
        }
        var connectionSharingEnabled = redis.getPool() == null || !redis.getPool().isEnabled();
        if (redis.getShareNativeConnections() != null) {
            connectionSharingEnabled = redis.getShareNativeConnections();
        }
        LOGGER.info("Redis native connection sharing is turned [{}]", BooleanUtils.toStringOnOff(connectionSharingEnabled));
        factory.setShareNativeConnection(connectionSharingEnabled);

        if (initialize) {
            factory.afterPropertiesSet();
        }
        return factory;
    }
New redis connection factory.

@param redis         the redis
@param initialize    the initialize
@param casSslContext the cas ssl context
@return the redis connection factory
support/cas-server-support-redis-core/src/main/java/org/apereo/cas/redis/core/RedisObjectFactory.java