public function __construct(array $config) { if (!extension_loaded('memcached')) { throw Error::require_extension('memcached'); } $memcached = new \Memcached(); if (isset($config['servers'])) { $memcached->addServers($config['servers']); } else { list($host, $port) = \Lysine\array_get($config, 'server') ?: $this->default_server; $memcached->addServer($host, $port); } if (isset($config['life_time'])) { $this->life_time = $config['life_time']; } if (isset($config['prefix'])) { $this->setPrefix($config['prefix']); } if (isset($config['options'])) { foreach ($config['options'] as $key => $val) { $memcache->setOption($key, $val); } } $this->memcached = $memcached; }
public static function get($path) { $path = is_array($path) ? $path : func_get_args(); return $path ? \Lysine\array_get(self::$config, $path) : self::$config; }
function cookie($path = null) { if ($path === null) { return $_COOKIE; } return \Lysine\array_get($_COOKIE, is_array($path) ? $path : func_get_args()); }