public static <K, V> CasRedisTemplate<K, V> newRedisTemplate(
        final RedisConnectionFactory connectionFactory,
        final RedisSerializer<?> valueSerializer) {
        val template = new DefaultCasRedisTemplate<K, V>();

        val stringRedisSerializer = new StringRedisSerializer();

        template.setKeySerializer(stringRedisSerializer);
        template.setHashKeySerializer(stringRedisSerializer);
        
        val compressedSerializer = new Lz4CompressionRedisSerializer(valueSerializer);
        template.setValueSerializer(compressedSerializer);
        template.setHashValueSerializer(compressedSerializer);

        template.setConnectionFactory(connectionFactory);
        return template;
    }
New redis template.

@param <K>               the type parameter
@param <V>               the type parameter
@param connectionFactory the connection factory
@param valueSerializer   the value serializer
@return the cas redis template
support/cas-server-support-redis-core/src/main/java/org/apereo/cas/redis/core/RedisObjectFactory.java