Configure the "lsw_memcache.pools" section

@return ArrayNodeDefinition
503231
private function addClientsSection()
    {
        $tree = new TreeBuilder();
        $node = $tree->root('pools');

        $node
            ->requiresAtLeastOneElement()
            ->useAttributeAsKey('name')
            ->prototype('array')
                ->children()
                    ->arrayNode('servers')
                        ->requiresAtLeastOneElement()
                        ->prototype('array')
                            ->children()
                                ->scalarNode('host')
                                	->cannotBeEmpty()
                                	->isRequired()
                               	->end()
                                ->scalarNode('tcp_port')
                                    ->defaultValue(11211)
                                    ->validate()
                                    ->ifTrue(function ($v) { return !is_numeric($v); })
                                        ->thenInvalid('port must be numeric')
                                    ->end()
                                ->end()
                                ->scalarNode('udp_port')
                                    ->defaultValue(0)
                                    ->validate()
                                    ->ifTrue(function ($v) { return !is_numeric($v); })
                                        ->thenInvalid('port must be numeric')
                                    ->end()
                                ->end()
                                ->booleanNode('persistent')
                                	->defaultTrue()
                                ->end()
                                ->scalarNode('weight')
                                    ->defaultValue(1)
                                    ->validate()
                                    ->ifTrue(function ($v) { return !is_numeric($v); })
                                        ->thenInvalid('weight must be numeric')
                                    ->end()
                                ->end()
                                ->scalarNode('timeout')
	                                ->defaultValue(1)
	                                ->validate()
	                                ->ifTrue(function ($v) { return !is_numeric($v); })
	                                	->thenInvalid('timeout must be numeric')
	                                ->end()
                                ->end()
                                ->scalarNode('retry_interval')
	                                ->defaultValue(15)
	                                ->validate()
	                                ->ifTrue(function ($v) { return !is_numeric($v); })
	                                	->thenInvalid('retry_interval must be numeric')
	                                ->end()
                                ->end()
                        	->end()
                        ->end()
                    ->end()
                    ->append($this->addMemcacheOptionsSection())
                ->end()
            ->end()
        ->end();

        return $node;
    }
427956
public static function configure($memcacheContainer = null) {
    $handler = new MemcacheSessionHandler($memcacheContainer);

    session_set_save_handler($handler, true);

    /**
     * Set so that it is clear that Memcache is being used for session handling,
     * as retrieving session.save_handler just returns "user".
     */
    session_save_path("Memcache");
  }
726965
protected function addKinesisConfiguration(ArrayNodeDefinition $rootNode) {
        $rootNode->children()
            ->arrayNode('kinesis')
                ->children()
                    ->scalarNode('api_version')->defaultValue('2013-12-02')->end()
                    ->scalarNode('region')->isRequired()->end()
                    ->arrayNode('consumer')
                        ->children()
                            ->scalarNode('recovery_file')->isRequired()->end()
                            ->scalarNode('key')->isRequired()->end()
                            ->scalarNode('secret')->isRequired()->end()
                        ->end()
                    ->end()
                    ->arrayNode('producer')
                        ->children()
                            ->scalarNode('key')->isRequired()->end()
                            ->scalarNode('secret')->isRequired()->end()
                        ->end()
                    ->end()
                ->end()
            ->end()
        ->end();
    }
1090801
private function addDbalSection(ArrayNodeDefinition $node)
    {
        $node
            ->children()
            ->arrayNode('dbal')
                ->beforeNormalization()
                    ->ifTrue(static function ($v) {
                        return is_array($v) && ! array_key_exists('connections', $v) && ! array_key_exists('connection', $v);
                    })
                    ->then(static function ($v) {
                        // Key that should not be rewritten to the connection config
                        $excludedKeys = ['default_connection' => true, 'types' => true, 'type' => true];
                        $connection   = [];
                        foreach ($v as $key => $value) {
                            if (isset($excludedKeys[$key])) {
                                continue;
                            }
                            $connection[$key] = $v[$key];
                            unset($v[$key]);
                        }
                        $v['default_connection'] = isset($v['default_connection']) ? (string) $v['default_connection'] : 'default';
                        $v['connections']        = [$v['default_connection'] => $connection];

                        return $v;
                    })
                ->end()
                ->children()
                    ->scalarNode('default_connection')->end()
                ->end()
                ->fixXmlConfig('type')
                ->children()
                    ->arrayNode('types')
                        ->useAttributeAsKey('name')
                        ->prototype('array')
                            ->beforeNormalization()
                                ->ifString()
                                ->then(static function ($v) {
                                    return ['class' => $v];
                                })
                            ->end()
                            ->children()
                                ->scalarNode('class')->isRequired()->end()
                                ->booleanNode('commented')->defaultNull()->end()
                            ->end()
                        ->end()
                    ->end()
                ->end()
                ->fixXmlConfig('connection')
                ->append($this->getDbalConnectionsNode())
            ->end();
    }
1139614
public static function conn() {

		if (static::$_oConn !== NULL) {
			return static::$_oConn;
		}

		$aConfig = Config::get('memcache');

		$lServer =& $aConfig['server'][static::_CONFIG];
		if (!is_array($lServer)) {
			throw new \Exception('memcache config "' . static::_CONFIG . '" not found');
		}

		if ($aConfig['enable']) {
			$oConn = new \Memcached();
			$oConn->setOptions($aConfig['option']);
			$oConn->addServers($lServer);
		} else {
			$oConn = new MemcacheFake();
		}

		return static::$_oConn = $oConn;
	}
958840
public function configure(ArrayNodeDefinition $builder)
    {
        $paths = $builder->children()->arrayNode('path')->children();
        foreach (array('resources', 'base') as $namespaceType) {
            $paths->scalarNode($namespaceType);
        }
        $builder->children()->variableNode('resource_map');
        $builder->children()->scalarNode('factory_class');
    }
491681
public function init()
    {
        $this->db = \PHPDaemon\Clients\Mongo\Pool::getInstance($this->config->mongoclientname->value);
        $this->cache = \PHPDaemon\Clients\Memcache\Pool::getInstance($this->config->memcacheclientname->value);
        if (!isset($this->config->limitinstances)) {
            $this->log('missing \'limitInstances\' directive');
        }
    }
889041
private function addMetadataSection(ArrayNodeDefinition $node)
    {
        $node
            ->children()
                ->arrayNode('metadata')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->booleanNode('use_cache')->defaultTrue()->end()
                        ->scalarNode('cache_dir')->cannotBeEmpty()->defaultValue('%kernel.cache_dir%/tbbc_cache')->end()
                    ->end()
                ->end()
            ->end()
        ;
    }
891683
private function addPoolsSection(ArrayNodeDefinition $node)
    {
        $node
            ->children()
                ->arrayNode('pools')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->arrayNode('method')
                            ->addDefaultsIfNotSet()
                            ->children()
                                ->variableNode('templates')->defaultValue([
                                    '_form.html' => 'EkynaPaymentBundle:Admin/Method:_form.html',
                                    'show.html'  => 'EkynaPaymentBundle:Admin/Method:show.html',
                                    'new.html'   => 'EkynaPaymentBundle:Admin/Method:new.html',
                                ])->end()
                                ->scalarNode('parent')->end()
                                ->scalarNode('entity')->defaultValue('Ekyna\Bundle\PaymentBundle\Entity\Method')->end()
                                ->scalarNode('controller')->defaultValue('Ekyna\Bundle\PaymentBundle\Controller\Admin\MethodController')->end()
                                ->scalarNode('operator')->end()
                                ->scalarNode('repository')->defaultValue('Ekyna\Bundle\PaymentBundle\Entity\MethodRepository')->end()
                                ->scalarNode('form')->defaultValue('Ekyna\Bundle\PaymentBundle\Form\Type\MethodType')->end()
                                ->scalarNode('table')->defaultValue('Ekyna\Bundle\PaymentBundle\Table\Type\MethodType')->end()
                                ->scalarNode('event')->end()
                            ->end()
                        ->end()
                    ->end()
                ->end()
            ->end()
        ;
    }
218788
private function addServiceSection(ArrayNodeDefinition $node)
    {
        $node
            ->children()
                ->arrayNode('service')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->scalarNode('class')
                            ->defaultValue(Service\Queue::class)->cannotBeEmpty()
                        ->end()
                        ->scalarNode('alias')
                            ->defaultValue('queue')->cannotBeEmpty()
                        ->end()
                        ->scalarNode('storage')
                            ->defaultValue('redis')->cannotBeEmpty()
                        ->end()
                    ->end()
                ->end()
            ->end();
    }
69463
public function appendConfiguration(ArrayNodeDefinition $rootNode)
    {
        $rootNode
            ->children()
                ->arrayNode('messages')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->arrayNode('languages')->performNoDeepMerging()->prototype('scalar')->end()->defaultValue(array('nl', 'en', 'fr'))->end()
                        ->booleanNode('overwrite_compatibility')->defaultTrue()->end()
                        ->scalarNode('yaz_cleanup')->end()
                    ->end()
                ->end()
            ->end()
        ;
    }
1295794
public function configure(ArrayNodeDefinition $builder) {
    $children = $builder->children();
    $children->scalarNode('phantom_server')->isRequired()->end();
    $children->scalarNode('template_cache')->defaultNull()->end();
  }
868385
private function createCachePluginNode()
    {
        $builder = new TreeBuilder('config');
        // Keep compatibility with symfony/config < 4.2
        if (!method_exists($builder, 'getRootNode')) {
            $config = $builder->root('config');
        } else {
            $config = $builder->getRootNode();
        }

        $config
            ->fixXmlConfig('method')
            ->fixXmlConfig('respect_response_cache_directive')
            ->addDefaultsIfNotSet()
            ->validate()
                ->ifTrue(function ($config) {
                    // Cannot set both respect_cache_headers and respect_response_cache_directives
                    return isset($config['respect_cache_headers'], $config['respect_response_cache_directives']);
                })
                ->thenInvalid('You can\'t provide config option "respect_cache_headers" and "respect_response_cache_directives" simultaniously. Use "respect_response_cache_directives" instead.')
            ->end()
            ->children()
                ->scalarNode('cache_key_generator')
                    ->info('This must be a service id to a service implementing '.CacheKeyGenerator::class)
                ->end()
                ->integerNode('cache_lifetime')
                    ->info('The minimum time we should store a cache item')
                ->end()
                ->integerNode('default_ttl')
                    ->info('The default max age of a Response')
                ->end()
                ->enumNode('hash_algo')
                    ->info('Hashing algorithm to use')
                    ->values(hash_algos())
                    ->cannotBeEmpty()
                ->end()
                ->arrayNode('methods')
                    ->info('Which request methods to cache')
                    ->defaultValue(['GET', 'HEAD'])
                    ->prototype('scalar')
                        ->validate()
                            ->ifTrue(function ($v) {
                                /* RFC7230 sections 3.1.1 and 3.2.6 except limited to uppercase characters. */
                                return preg_match('/[^A-Z0-9!#$%&\'*+\-.^_`|~]+/', $v);
                            })
                            ->thenInvalid('Invalid method: %s')
                        ->end()
                    ->end()
                ->end()
                ->scalarNode('respect_cache_headers')
                    ->info('Whether we should care about cache headers or not [DEPRECATED]')
                    ->beforeNormalization()
                        ->always(function ($v) {
                            @trigger_error('The option "respect_cache_headers" is deprecated since version 1.3 and will be removed in 2.0. Use "respect_response_cache_directives" instead.', E_USER_DEPRECATED);

                            return $v;
                        })
                    ->end()
                    ->validate()
                        ->ifNotInArray([null, true, false])
                        ->thenInvalid('Value for "respect_cache_headers" must be null or boolean')
                    ->end()
                ->end()
                ->variableNode('respect_response_cache_directives')
                    ->info('A list of cache directives to respect when caching responses')
                    ->validate()
                        ->always(function ($v) {
                            if (is_null($v) || is_array($v)) {
                                return $v;
                            }

                            throw new InvalidTypeException();
                        })
                    ->end()
                ->end()
            ->end()
        ;

        $cache = $builder->root('cache');
        $cache
            ->canBeEnabled()
            ->info('Configure HTTP caching, requires the php-http/cache-plugin package')
            ->addDefaultsIfNotSet()
            ->validate()
                ->ifTrue(function ($v) {
                    return !empty($v['enabled']) && !class_exists(CachePlugin::class);
                })
                ->thenInvalid('To use the cache plugin, you need to require php-http/cache-plugin in your project')
            ->end()
            ->children()
                ->scalarNode('cache_pool')
                    ->info('This must be a service id to a service implementing '.CacheItemPoolInterface::class)
                    ->isRequired()
                    ->cannotBeEmpty()
                ->end()
                ->scalarNode('stream_factory')
                    ->info('This must be a service id to a service implementing '.StreamFactory::class)
                    ->defaultValue('httplug.stream_factory')
                    ->cannotBeEmpty()
                ->end()
            ->end()
            ->append($config)
        ;

        return $cache;
    }
953555
protected function configuration_definition() {
        global $OUTPUT;

        $form = $this->_form;
        $version = phpversion('memcached');
        $hasrequiredversion = ($version || version_compare($version, cachestore_memcached::REQUIRED_VERSION, '>='));

        if (!$hasrequiredversion) {
            $notify = new \core\output\notification(nl2br(get_string('upgrade200recommended', 'cachestore_memcached')),
                \core\output\notification::NOTIFY_WARNING);
            $form->addElement('html', $OUTPUT->render($notify));
        }

        $form->addElement('textarea', 'servers', get_string('servers', 'cachestore_memcached'), array('cols' => 75, 'rows' => 5));
        $form->addHelpButton('servers', 'servers', 'cachestore_memcached');
        $form->addRule('servers', get_string('required'), 'required');
        $form->setType('servers', PARAM_RAW);

        $form->addElement('selectyesno', 'compression', get_string('usecompression', 'cachestore_memcached'));
        $form->addHelpButton('compression', 'usecompression', 'cachestore_memcached');
        $form->setDefault('compression', 1);
        $form->setType('compression', PARAM_BOOL);

        $serialiseroptions = cachestore_memcached::config_get_serialiser_options();
        $form->addElement('select', 'serialiser', get_string('useserialiser', 'cachestore_memcached'), $serialiseroptions);
        $form->addHelpButton('serialiser', 'useserialiser', 'cachestore_memcached');
        $form->setDefault('serialiser', Memcached::SERIALIZER_PHP);
        $form->setType('serialiser', PARAM_INT);

        $form->addElement('text', 'prefix', get_string('prefix', 'cachestore_memcached'), array('size' => 16));
        $form->setType('prefix', PARAM_TEXT); // We set to text but we have a rule to limit to alphanumext.
        $form->addHelpButton('prefix', 'prefix', 'cachestore_memcached');
        $form->addRule('prefix', get_string('prefixinvalid', 'cachestore_memcached'), 'regex', '#^[a-zA-Z0-9\-_]+$#');
        $form->setForceLtr('prefix');

        $hashoptions = cachestore_memcached::config_get_hash_options();
        $form->addElement('select', 'hash', get_string('hash', 'cachestore_memcached'), $hashoptions);
        $form->addHelpButton('hash', 'hash', 'cachestore_memcached');
        $form->setDefault('serialiser', Memcached::HASH_DEFAULT);
        $form->setType('serialiser', PARAM_INT);

        $form->addElement('selectyesno', 'bufferwrites', get_string('bufferwrites', 'cachestore_memcached'));
        $form->addHelpButton('bufferwrites', 'bufferwrites', 'cachestore_memcached');
        $form->setDefault('bufferwrites', 0);
        $form->setType('bufferwrites', PARAM_BOOL);

        if ($hasrequiredversion) {
            // Only show this option if we have the required version of memcache extension installed.
            // If it's not installed then this option does nothing, so there is no point in displaying it.
            $form->addElement('selectyesno', 'isshared', get_string('isshared', 'cachestore_memcached'));
            $form->addHelpButton('isshared', 'isshared', 'cachestore_memcached');
            $form->setDefault('isshared', 0);
            $form->setType('isshared', PARAM_BOOL);
        }

        $form->addElement('header', 'clusteredheader', get_string('clustered', 'cachestore_memcached'));

        $form->addElement('checkbox', 'clustered', get_string('clustered', 'cachestore_memcached'));
        $form->setDefault('checkbox', false);
        $form->addHelpButton('clustered', 'clustered', 'cachestore_memcached');

        $form->addElement('textarea', 'setservers', get_string('setservers', 'cachestore_memcached'),
                array('cols' => 75, 'rows' => 5));
        $form->addHelpButton('setservers', 'setservers', 'cachestore_memcached');
        $form->disabledIf('setservers', 'clustered');
        $form->setType('setservers', PARAM_RAW);
    }
352391
protected function addIndividualConsumerConfiguration(ArrayNodeDefinition $node)
    {
        $node
            ->normalizeKeys(false)
            ->children()
                ->integerNode('messages')
                    ->min(0)
                    ->defaultNull()
                ->end()
                ->integerNode('memory-limit')
                    ->defaultNull()
                ->end()
                ->booleanNode('debug')
                    ->defaultNull()
                ->end()
                ->booleanNode('without-signals')
                    ->defaultNull()
                ->end()
                ->scalarNode('command')
                    ->defaultNull()
                ->end()
                ->arrayNode('worker')
                    ->children()
                        ->integerNode('count')
                            ->min(1)
                            ->defaultNull()
                        ->end()
                        ->integerNode('startsecs')
                            ->min(0)
                            ->defaultNull()
                        ->end()
                        ->booleanNode('autorestart')
                            ->defaultNull()
                        ->end()
                        ->enumNode('stopsignal')
                            ->values(array('TERM', 'INT', 'KILL'))
                            ->defaultNull()
                        ->end()
                        ->booleanNode('stopasgroup')
                            ->defaultNull()
                        ->end()
                        ->integerNode('stopwaitsecs')
                            ->min(0)
                            ->defaultNull()
                        ->end()
                    ->end()
                ->end()
            ->end()
        ;
    }
65072
public function save()
    {
        if (null !== $this->cache) {
            $this->loadConfig(null);
            $this->cache->save($this->pool);
        }
        return $this;
    }
220405
protected function createMemcachedStore()
    {
        $serverArray    = $this->config['servers'];
        $persistent     = boolval($this->config['persistent']);
        $name           = trim($this->config['server_name']);
        $prefix         = trim($this->config['prefix']);

        if ($persistent && (strlen($name) > 0)) {
            $memcached  = new Memcached($name);
        } else {
            $memcached  = new Memcached();
        }

        if (!sizeof($memcached->getServerList())) {
            $memcached->addServers($serverArray);
        }

        return new MemcachedStore($memcached, $prefix);
    }