protected function connect() { $this->_memcache = new \Memcache(); if (!$this->_memcache->connect($this->config['host'], $this->config['port'])) { throw new UpaddException("Connect to memcache server failure({$this->config['host']}:{$this->config['port']})!"); } }
public function __construct($server = 'localhost', $port = 11211) { if (empty(self::$memcache)) { self::$memcache = new \Memcache(); self::$memcache->connect($server, $port) or die("Could not connect"); } }
function connect() { if (!$this->connected) { $this->cache->connect($this->aConf['host'], $this->aConf['port']) or die("Could not connect"); } return $this->connected; }
public function __construct($host = 'localhost', $port = 11211) { $this->memcache = new \Memcache(); if (!$this->memcache->connect($host, $port)) { throw new \Exception('Unable to connect to Memcache server'); } }
public function __construct() { if (class_exists('Memcache')) { $this->memcache = new Memcache(); $config = Vinal::app()->config("cache"); $this->memcache->connect($config->server, $config->port); } }
/** * Try connect to memcache server */ public static function connect() { if (!self::$connectTrying && class_exists('Memcache', false)) { self::$server = new Memcache(); self::$connected = @self::$server->connect('localhost', 11211); } self::$connectTrying = true; }
/** * 构造函数 * @param string $host Redis 服务器的主机名或IP地址或者为服务器组相关信息 * @param int $port 端口号 * @param int $timeout 超时时间 */ private function __construct($host = 'localhost', $port = 11211, $timeout = 60) { $this->redis = new \redis(); if (is_array($host)) { $this->redis->connect($host['host'], $host['port']); } else { $this->redis->connect($host, $port); } }
/** * * @param Oops_Config $config */ public function __construct($config) { $config = new Oops_Config(array('host' => 'localhost', 'port' => 11211, 'timeout' => 1)); $this->_m = new Memcache(); $this->_m->connect($config->host, $config->port, $config->timeout); if ($config->compress) { $this->_compress = MEMCACHE_COMPRESSED; } }
public function open($path = null, $name = null) { if (!class_exists('\\Memcache')) { throw new \RuntimeException("Use Session\\Memcache need memcache extension installed."); } $this->memcache = new \Memcache(); $this->memcache->connect($this->injectors['host'], $this->injectors['port'], $this->injectors['timeout']); return true; }
public function __construct($host = 'localhost', $port = 11211, $prefix = '') { if (!self::isAvailable()) { throw new Exception("PHP extension 'memcache' is not loaded."); } $this->prefix = $prefix; $this->memcache = new Memcache(); $this->memcache->connect($host, $port); }
/** * @return \Memcache */ public function getInstance() { if (is_null($this->instance)) { $this->instance = new \Memcache(); $this->instance->connect("localhost", 11211); return $this->instance; } return $this->instance; }
/** * construct PhealMemcache, * @param array $options optional config array, valid keys are: host, port */ public function __construct($options = array()) { // add options if (is_array($options) && count($options)) { $this->options = array_merge($this->options, $options); } $this->memcache = new Memcache(); $this->memcache->connect($this->options['host'], $this->options['port']); }
public function __construct($server = 'localhost', $port = 11211) { if (empty(self::$memcache)) { if (!class_exists('Memcache')) { throw new \Exception('You need to have the php memcached extension'); } self::$memcache = new \Memcache(); self::$memcache->connect($server, $port) or die("Could not connect"); } }
/** * Open up the backend * * @param string $savePath * @param string $sessionName * @return boolean */ public function open($savePath, $sessionName) { $this->_backend = new Memcache(); // Open a persistent or regular connection if ($this->_config['persistent']) { $this->_backend->pconnect($this->_config['hostname'], $this->_config['port'], $this->_config['timeout_connect']); } else { $this->_backend->connect($this->_config['hostname'], $this->_config['port'], $this->_config['timeout_connect']); } }
/** * @param string $sHost = '127.0.0.1' * @param int $iPost = 11211 * @param int $iExpire = 43200 */ private function __construct($sHost = '127.0.0.1', $iPost = 11211, $iExpire = 43200) { $this->sHost = $sHost; $this->iPost = $iPost; $this->iExpire = 0 < $iExpire ? $iExpire : 43200; $this->oMem = new \Memcache(); if (!$this->oMem->connect($this->sHost, $this->iPost)) { $this->oMem = null; } }
/** * @param $host * @param int $port */ public function connect($host, $port = 11211) { try { $this->cache = new \Memcache(); $this->cache->connect($host, $port); } catch (\Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; exit; } }
/** * Singleton instance which means this is redundant * @param string $host * @param integer|null $port * @param integer|null $timeout */ protected function __construct($host, $port = null, $timeout = null) { if (class_exists('\\Memcache')) { $this->memcache = new \Memcache($host, $port, $timeout); $this->connected = $this->memcache->connect($host); } else { // @codeCoverageIgnoreStart $this->connected = false; // @codeCoverageIgnoreEnd } }
/** * Creates a new cache_ApcHandler instance * @access public * @param string $host The host where memcache is listening for connections * @param integer $port The port where memcache is listening for connections */ public function __construct($host, $port, $useExceptions = false) { $this->useExceptions = $useExceptions; $this->memcache = new Memcache(); if (is_null($host)) { return; } if (!$this->memcache->connect($host, $port)) { throw new cache_CouldNotConnectException('Could not connect to Memcache server'); } }
/** * Constructor * * Instantiate the memcache cache object * * @param string $host * @param int $port * @throws Exception * @return \Pop\Cache\Adapter\Memcached */ public function __construct($host = 'localhost', $port = 11211) { if (!class_exists('Memcache')) { throw new Exception('Error: Memcache is not available.'); } $this->memcache = new \Memcache(); if (!$this->memcache->connect($host, (int) $port)) { throw new Exception('Error: Unable to connect to the memcached server.'); } $this->version = $this->memcache->getVersion(); }
/** * @return \Memcache */ private static function getMemcache() { if (self::$memcache !== null) { return self::$memcache; } $config = self::getConfig(); self::$defaultExpiration = $config['defaultExpiration']; self::$memcache = new \Memcache(); self::$memcache->connect($config['server'], $config['port']); return self::$memcache; }
public function __construct(\Memcache $connection = null) { if (!extension_loaded('memcache')) { throw new MissingExtensionException('PHP extension memcache ist not loaded. You cannot use this cache.'); } if (!$connection) { $this->connection = new \Memcache(); if (!$this->connection->connect('localhost', 11211)) { throw new ExtensionException('Cannot connect to memcache on localhost:11211'); } } }
public function _before(TestCase $test) { if (class_exists('\\Memcache')) { $this->memcache = new \Memcache(); $this->memcache->connect($this->config['host'], $this->config['port']); } elseif (class_exists('\\Memcached')) { $this->memcache = new \Memcached(); $this->memcache->addServer($this->config['host'], $this->config['port']); } else { throw new ModuleConfigException(__CLASS__, 'Memcache classes not loaded'); } }
public function __construct($config) { $this->handler = new Memcache(); if (isset($config['keep-alive']) && $config['keep-alive']) { $fd = $this->handler->pconnect($config['host'], $config['port'], TXConst::minute); } else { $fd = $this->handler->connect($config['host'], $config['port']); } if (!$fd) { throw new TXException(4004, array($config['host'], $config['port'])); } }
/** * 构造方法 * * @param Monkey\App $app * * @throws \Exception */ public function __construct($app) { if (!extension_loaded('apc')) { new \Exception('会话出错:没有安装Memcache扩展。', 2048); } $this->app = $app; $this->config = $app->config()->getComponentConfig('session', 'memcache'); $this->handler = new \Memcache(); if (!$this->handler->connect($this->config['host'], $this->config['port'])) { new \Exception('会话出错:Memcache连接失败。', 2048); } $this->start(); }
public function __construct($host = self::DEFAULT_HOST, $port = self::DEFAULT_PORT) { $this->instance = new \Memcache(); try { try { $this->instance->pconnect($host, $port); } catch (BaseException $e) { $this->instance->connect($host, $port); } $this->alive = true; } catch (BaseException $e) { // bad luck. } }
protected function __construct($config) { if (empty($config['host']) || empty($config['port'])) { throw new \HuiLib\Error\Exception("Memcache配置信息错误"); } $this->config = $config; if (!empty($config['prefix'])) { $this->prefix = $config['prefix']; } $this->connect = new \Memcache(); if (!$this->connect->connect($config['host'], $config['port'])) { throw new \HuiLib\Error\Exception("Memcache连接失败,请确认已安装该拓展"); } }
/** * @param string $sHost = '127.0.0.1' * @param int $iPost = 11211 * @param int $iExpire = 43200 * @param string $sKeyPrefix = '' */ private function __construct($sHost = '127.0.0.1', $iPost = 11211, $iExpire = 43200, $sKeyPrefix = '') { $this->sHost = $sHost; $this->iPost = $iPost; $this->iExpire = 0 < $iExpire ? $iExpire : 43200; $this->oMem = new \Memcache(); if (!$this->oMem->connect($this->sHost, $this->iPost)) { $this->oMem = null; } $this->sKeyPrefix = $sKeyPrefix; if (!empty($this->sKeyPrefix)) { $this->sKeyPrefix = \preg_replace('/[^a-zA-Z0-9_]/', '_', rtrim(trim($this->sKeyPrefix), '\\/')) . '/'; } }
public function __construct($host = 'localhost', $port = 11211, $prefix = '', Nette\Context $context = NULL) { if (!self::isAvailable()) { throw new \NotSupportedException("PHP extension 'memcache' is not loaded."); } $this->prefix = $prefix; $this->context = $context; $this->memcache = new \Memcache(); Nette\Debug::tryError(); $this->memcache->connect($host, $port); if (Nette\Debug::catchError($msg)) { throw new \InvalidStateException($msg); } }
public function __construct($host = 'localhost', $port = 11211, $prefix = '', IJournal $journal = NULL) { if (!self::isAvailable()) { throw new Nette\NotSupportedException("PHP extension 'memcache' is not loaded."); } $this->prefix = $prefix; $this->journal = $journal; $this->memcache = new \Memcache(); Nette\Diagnostics\Debugger::tryError(); $this->memcache->connect($host, $port); if (Nette\Diagnostics\Debugger::catchError($e)) { throw new Nette\InvalidStateException('Memcache::connect(): ' . $e->getMessage(), 0, $e); } }
/** * Constructor * * @param array $connectionData Connection Data parsed by parse_url() * @return self */ public function __construct(array $connectionData) { if (!class_exists("Memcache", false)) { error("Memcache Extension not installed - Update your PHP configuration"); } $this->memcache = new Memcache(); $host = $connectionData["host"]; $port = arrayValue($connectionData, "port"); $port = $port ? $port : 11211; $connectState = $this->memcache->connect($host, $port); if (!$connectState) { error("Could not connect to Memcache Server at " . $host . ":" . $port); } }