本文整理汇总了PHP中Memcache::connect方法的典型用法代码示例。如果您正苦于以下问题:PHP Memcache::connect方法的具体用法?PHP Memcache::connect怎么用?PHP Memcache::connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Memcache
的用法示例。
在下文中一共展示了Memcache::connect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: connect
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']})!");
}
}
示例2: __construct
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");
}
}
示例3: connect
function connect()
{
if (!$this->connected) {
$this->cache->connect($this->aConf['host'], $this->aConf['port']) or die("Could not connect");
}
return $this->connected;
}
示例4: __construct
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');
}
}
示例5: __construct
public function __construct()
{
if (class_exists('Memcache')) {
$this->memcache = new Memcache();
$config = Vinal::app()->config("cache");
$this->memcache->connect($config->server, $config->port);
}
}
示例6: connect
/**
* 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;
}
示例7: __construct
/**
* 构造函数
* @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);
}
}
示例8: __construct
/**
*
* @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;
}
}
示例9: open
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;
}
示例10: __construct
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);
}
示例11: getInstance
/**
* @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;
}
示例12: __construct
/**
* 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']);
}
示例13: __construct
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");
}
}
示例14: open
/**
* 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']);
}
}
示例15: __construct
/**
* @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;
}
}