protected function loadPhpredisClient(array $client, ContainerBuilder $container)
    {
        $connectionCount = count($client['dsns']);

        if (1 !== $connectionCount) {
            throw new \RuntimeException('Support for RedisArray is not yet implemented.');
        }

        /** @var \Snc\RedisBundle\DependencyInjection\Configuration\RedisDsn $dsn */
        $dsn = $client['dsns'][0];

        $phpRedisVersion = phpversion('redis');
        if (version_compare($phpRedisVersion, '4.0.0') >= 0 && $client['logging']) {
            $client['logging'] = false;
            @trigger_error(sprintf('Redis logging is not supported on PhpRedis %s and has been automatically disabled, disable logging in config to suppress this warning', $phpRedisVersion), E_USER_WARNING);
        }

        $phpredisClientclass = $container->getParameter('snc_redis.phpredis_client.class');
        if ($client['logging']) {
            $phpredisClientclass = $container->getParameter('snc_redis.phpredis_connection_wrapper.class');
        }
        $phpredisDef = new Definition($phpredisClientclass);
        $phpredisDef->setFactory(array(
            new Definition(PhpredisClientFactory::class, [new Reference('snc_redis.logger')]),
            'create'
        ));
        $phpredisDef->addArgument($phpredisClientclass);
        $phpredisDef->addArgument((string) $dsn);
        $phpredisDef->addArgument($client['options']);
        $phpredisDef->addArgument($client['alias']);
        $phpredisDef->addTag('snc_redis.client', array('alias' => $client['alias']));
        $phpredisDef->setPublic(false);

        // Older version of phpredis extension do not support lazy loading
        $minimumVersionForLazyLoading = '4.1.1';
        $supportsLazyServices = version_compare($phpRedisVersion, $minimumVersionForLazyLoading, '>=');
        $phpredisDef->setLazy($supportsLazyServices);
        if (!$supportsLazyServices) {
            @trigger_error(
                sprintf('Lazy loading Redis is not supported on PhpRedis %s. Please update to PhpRedis %s or higher.', $phpRedisVersion, $minimumVersionForLazyLoading),
                E_USER_WARNING
            );
        }

        $phpredisId = sprintf('snc_redis.%s', $client['alias']);
        $container->setDefinition($phpredisId, $phpredisDef);
    }
protected function loadPhpredisClient(array $client, ContainerBuilder $container)
    {
        $connectionCount = count($client['dsns']);

        if (1 !== $connectionCount) {
            throw new \RuntimeException('Support for RedisArray is not yet implemented.');
        }

        /** @var \Snc\RedisBundle\DependencyInjection\Configuration\RedisDsn $dsn */
        $dsn = $client['dsns'][0];

        $phpRedisVersion = phpversion('redis');
        if (version_compare($phpRedisVersion, '4.0.0') >= 0 && $client['logging']) {
            $client['logging'] = false;
            @trigger_error(sprintf('Redis logging is not supported on PhpRedis %s and has been automatically disabled, disable logging in config to suppress this warning', $phpRedisVersion), E_USER_WARNING);
        }

        $phpredisClientclass = $container->getParameter('snc_redis.phpredis_client.class');
        if ($client['logging']) {
            $phpredisClientclass = $container->getParameter('snc_redis.phpredis_connection_wrapper.class');
        }
        $phpredisDef = new Definition($phpredisClientclass);
        $phpredisDef->setFactory(array(
            new Definition(PhpredisClientFactory::class, [new Reference('snc_redis.logger')]),
            'create'
        ));
        $phpredisDef->addArgument($phpredisClientclass);
        $phpredisDef->addArgument((string) $dsn);
        $phpredisDef->addArgument($client['options']);
        $phpredisDef->addArgument($client['alias']);
        $phpredisDef->addTag('snc_redis.client', array('alias' => $client['alias']));
        $phpredisDef->setPublic(false);

        // Older version of phpredis extension do not support lazy loading
        $minimumVersionForLazyLoading = '4.1.1';
        $supportsLazyServices = version_compare($phpRedisVersion, $minimumVersionForLazyLoading, '>=');
        $phpredisDef->setLazy($supportsLazyServices);
        if (!$supportsLazyServices) {
            @trigger_error(
                sprintf('Lazy loading Redis is not supported on PhpRedis %s. Please update to PhpRedis %s or higher.', $phpRedisVersion, $minimumVersionForLazyLoading),
                E_USER_WARNING
            );
        }

        $phpredisId = sprintf('snc_redis.%s', $client['alias']);
        $container->setDefinition($phpredisId, $phpredisDef);
    }
protected function loadPhpredisClient ( array $ client , ContainerBuilder $ container ) { $ connectionCount = count ( $ client [ 'dsns' ] ) ; if ( 1 !== $ connectionCount ) { throw new \ RuntimeException ( 'Support for RedisArray is not yet implemented.' ) ; } /** @var \Snc\RedisBundle\DependencyInjection\Configuration\RedisDsn $dsn */ $ dsn = $ client [ 'dsns' ] [ 0 ] ; $ phpRedisVersion = phpversion ( 'redis' ) ; if ( version_compare ( $ phpRedisVersion , '4.0.0' ) >= 0 && $ client [ 'logging' ] ) { $ client [ 'logging' ] = false ; @ trigger_error ( sprintf ( 'Redis logging is not supported on PhpRedis %s and has been automatically disabled, disable logging in config to suppress this warning' , $ phpRedisVersion ) , E_USER_WARNING ) ; } $ phpredisClientclass = $ container -> getParameter ( 'snc_redis.phpredis_client.class' ) ; if ( $ client [ 'logging' ] ) { $ phpredisClientclass = $ container -> getParameter ( 'snc_redis.phpredis_connection_wrapper.class' ) ; } $ phpredisDef = new Definition ( $ phpredisClientclass ) ; $ phpredisDef -> setFactory ( array ( new Definition ( PhpredisClientFactory :: class , [ new Reference ( 'snc_redis.logger' ) ] ) , 'create' ) ) ; $ phpredisDef -> addArgument ( $ phpredisClientclass ) ; $ phpredisDef -> addArgument ( ( string ) $ dsn ) ; $ phpredisDef -> addArgument ( $ client [ 'options' ] ) ; $ phpredisDef -> addArgument ( $ client [ 'alias' ] ) ; $ phpredisDef -> addTag ( 'snc_redis.client' , array ( 'alias' => $ client [ 'alias' ] ) ) ; $ phpredisDef -> setPublic ( false ) ; // Older version of phpredis extension do not support lazy loading $ minimumVersionForLazyLoading = '4.1.1' ; $ supportsLazyServices = version_compare ( $ phpRedisVersion , $ minimumVersionForLazyLoading , '>=' ) ; $ phpredisDef -> setLazy ( $ supportsLazyServices ) ; if ( ! $ supportsLazyServices ) { @ trigger_error ( sprintf ( 'Lazy loading Redis is not supported on PhpRedis %s. Please update to PhpRedis %s or higher.' , $ phpRedisVersion , $ minimumVersionForLazyLoading ) , E_USER_WARNING ) ; } $ phpredisId = sprintf ( 'snc_redis.%s' , $ client [ 'alias' ] ) ; $ container -> setDefinition ( $ phpredisId , $ phpredisDef ) ; }
Loads a redis client using phpredis.

@param array            $client    A client configuration
@param ContainerBuilder $container A ContainerBuilder instance

@throws \RuntimeException
Loads a redis client using phpredis .