Creates a Memcached instance from the session options.

@param OptionsBag $sessionOptions

@return Memcached
1312
public function create(OptionsBag $sessionOptions)
    {
        $options = $this->parseOptions($sessionOptions);

        $connections = $this->parse($sessionOptions);

        $persistentId = null;
        if ($options['persistent']) {
            $persistentId = $this->parsePersistentId($connections, $options, $sessionOptions);
        }

        $class = $this->class;
        /** @var Memcached $memcached */
        $memcached = new $class(
            $persistentId,
            function (Memcached $memcached) use ($connections, $options) {
                $this->configure($memcached, $connections, $options);
            }
        );

        return $memcached;
    }
630857
protected function setOptions(array $options)
	{
		// Set name
		if (isset($options['name']))
		{
			session_name(md5($options['name']));
		}

		// Set id
		if (isset($options['id']))
		{
			session_id($options['id']);
		}

		// Set expire time
		if (isset($options['expire']))
		{
			$this->setExpire($options['expire']);
		}

		// Get security options
		if (isset($options['security']))
		{
			$this->security = explode(',', $options['security']);
		}

		if (isset($options['force_ssl']))
		{
			$this->force_ssl = (bool) $options['force_ssl'];
		}

		if (isset($options['cookie_domain']))
		{
			$this->cookie_domain = $options['cookie_domain'];
		}

		if (isset($options['cookie_path']))
		{
			$this->cookie_path = $options['cookie_path'];
		}

		// Sync the session maxlifetime
		if (!headers_sent())
		{
			ini_set('session.gc_maxlifetime', $this->getExpire());
		}

		return true;
	}
179013
public function create ($exclude = array (), $cache = FALSE)
	{
		
		// If we're not caching or there is no memcached object just call parent
		
		if ($cache === FALSE || !($this->memcached instanceof \Memcached))
		{
			return parent::create ($exclude);
		}
		
		// Call parent method
		
		$parent	= parent::create ($exclude);
		
		if ($parent === FALSE)
		{
			return FALSE;
		}
		
		// Cache
		
		$this->memcached->set ($this->getMemcachedID (), $this->getCacheAttributes (), $cache);
		
		// Return
		
		return $parent;
		
	}
1094140
public function create(PropertyAccess $conf)
    {
        $type = $conf->get(['main', 'session', 'type'], 'file');
        $options = $conf->get(['main', 'session', 'options'], []);
        $serverOpts = [
            'expiretime' => $conf->get(['main', 'session', 'ttl'], 86400),
            'prefix'     => $conf->get(['main', 'key']),
        ];

        switch (strtolower($type)) {
            case 'memcache':
                return new WriteCheckSessionHandler(
                    new MemcacheSessionHandler(
                        $this->connectionFactory->getMemcacheConnection($options, $serverOpts)
                    )
                );
            case 'memcached':
                return new WriteCheckSessionHandler(
                    new MemcachedSessionHandler(
                        $this->connectionFactory->getMemcachedConnection($options, $serverOpts)
                    )
                );
            case 'file':
                return new NativeFileSessionHandler(isset($options['save-path']) ? $options['save-path'] : null);
            case 'redis':
                return new WriteCheckSessionHandler(
                    new RedisSessionHandler(
                        $this->connectionFactory->getRedisConnection($options, $serverOpts)
                    )
                );
            case 'native':
                return new NativeSessionHandler();
        }

        throw new RuntimeException(sprintf('Unable to create the specified session handler "%s"', $type));
    }
805556
public function create($name, $options)
    {
        switch (strtolower($name)) {
            case 'apc':
            case 'apccache':
                $cache = $this->createApc();
                break;
            case 'array':
            case 'arraycache':
                $cache = new ArrayCache();
                break;
            case 'memcache':
            case 'memcachecache':
                $cache = $this->createMemcache($options);
                break;
            case 'memcached':
            case 'memcachedcache':
                $cache = $this->createMemcached($options);
                break;
            case 'redis':
            case 'rediscache':
                $cache = $this->createRedis($options);
                break;
            case 'wincache':
            case 'wincachecache':
                $cache = $this->createWincache();
                break;
            case 'xcache':
            case 'xcachecache':
                $cache = $this->createXcache();
                break;
            default:
                throw new RuntimeException(sprintf('Unnown cache type %s', $name));
        }

        return $cache;
    }
924814
public function create(array $options)
    {
        $entityClass = $this->getClassName($options['entity-table']);
        $closureClass = $this->getClassName($options['closure-table']);
        $useInnoDB = $options['use-innodb'];
        $stubPrefix = $useInnoDB ? '-innodb' : '';

        $path = $this->getPath($options['entity-table'], $options['migrations-path']);
        $stub = $this->getStub('migration' . $stubPrefix, 'migrations');

        $this->filesystem->put(
            $path,
            $this->parseStub($stub, [
            'entity_table' => $options['entity-table'],
            'entity_class' => $entityClass,
            'closure_table' => $options['closure-table'],
            'closure_class' => $closureClass,
            ])
        );

        return [$path];
    }
402890
public function connect(array $servers, $connectionId = null, array $options = [], array $credentials = [])
    {
        $memcached = $this->getMemcached(
            $connectionId, $credentials, $options
        );

        if (! $memcached->getServerList()) {
            // For each server in the array, we'll just extract the configuration and add
            // the server to the Memcached connection. Once we have added all of these
            // servers we'll verify the connection is successful and return it back.
            foreach ($servers as $server) {
                $memcached->addServer(
                    $server['host'], $server['port'], $server['weight']
                );
            }
        }

        return $this->validateConnection($memcached);
    }
836972
public function setConnection(\Memcached $memcached)
    {
        $this->connection = $memcached;

        if (!count($this->connection->getServerList())) {
            $this->configureServers();
        }

        $this->setOptions();
        return $this;
    }
446404
public function withOptions($options)
    {
        if (is_array($options)) {
            $options = new RequestOptions($options);
        }

        $this->options = $options;

        return $this;
    }
470043
public function setOptions($options)
    {
        if (!$options instanceof ModuleOptions) {
            $options = new ModuleOptions($options);
        }

        $this->options = $options;
        return $this;
    }
1109372
public static MemcachedClient create(final PippoSettings settings) {
        String host = settings.getString(HOST, "localhost:11211");
        String prot = settings.getString(PROT, "BINARY");
        CommandFactory protocol;
        switch (prot) {
            case "BINARY":
                protocol = new BinaryCommandFactory();
                break;
            case "TEXT":
                protocol = new TextCommandFactory();
                break;
            default:
                protocol = new BinaryCommandFactory();
                break;
        }
        String user = settings.getString(USER, "");
        String pass = settings.getString(PASS, "");
        List<String> autM = settings.getStrings(AUTM);
        String[] mechanisms = autM.toArray(new String[autM.size()]);
        return create(host, protocol, user, pass, mechanisms);
    }
83277
protected function buildCacheKey(array $assets, array $options)
    {
        $cachekey = $this->Request->getServerName();
        $cachekey .= "(asset(".implode('|', $assets).")(".implode('|', $options)."))";

        return $cachekey;
    }
893975
protected function parseConnectionsFromOptions(OptionsBag $options)
    {
        if ($options->has('connections')) {
            $connections = $options->get('connections');
        } elseif ($options->has('connection')) {
            $connections = [$options->get('connection')];
        } elseif ($options->has('host') || $options->has('port')) {
            Deprecated::warn('Specifying "host" and other options directly in session config', 1.0, 'Move them under the "connection" key.');

            $connections = [$options->all()];
        } else {
            $connections = [[]];
        }

        return array_map([$this, 'parseConnectionItemFromOptions'], $connections);
    }
319512
protected function parseOptions(OptionsBag $sessionOptions)
    {
        $options = $sessionOptions->get('options', []);

        if ($sessionOptions->get('prefix')) {
            Deprecated::warn('Specifying "prefix" directly in session config', 1.0, 'Move it under the "options" key.');

            $options['prefix'] = $sessionOptions->get('prefix');
        }

        return $options;
    }
152143
public function with($options)
    {
        $clone = clone $this;
        foreach ($options as $name => $value) {
            $clone->setOption($name, $value);
        }

        return $clone;
    }
872000
function MemcachedStore(options) {
    options = options || {};
    Store.call(this, options);

    this.prefix = options.prefix || "";
    this.ttl = options.ttl;
    if (!options.client) {
      if (!options.hosts) {
        options.hosts = "127.0.0.1:11211";
      }
      if (options.secret) {
        (this.crypto = require("crypto")), (this.secret = options.secret);
      }
      if (options.algorithm) {
        this.algorithm = options.algorithm;
      }

      options.client = new Memcached(options.hosts, options);
    }

    this.client = options.client;
  }
863634
public function write($session_id, $session_data)
    {
        return $this->memcached->set($session_id, $session_data, $this->expire);
    }