当前位置: 首页>>代码示例>>PHP>>正文


PHP Memcache::pconnect方法代码示例

本文整理汇总了PHP中Memcache::pconnect方法的典型用法代码示例。如果您正苦于以下问题:PHP Memcache::pconnect方法的具体用法?PHP Memcache::pconnect怎么用?PHP Memcache::pconnect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Memcache的用法示例。


在下文中一共展示了Memcache::pconnect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Class constructor
  *
  * @param $memcache_host, $memcache_port
  */
 public function __construct($memcache_host = '127.0.0.1', $memcache_port = 11211)
 {
     if (is_null($this->memcache) || !is_object($this->memcache)) {
         $this->memcache = new Memcache();
         if (!$this->memcache->pconnect($memcache_host, $memcache_port)) {
             throw new Exception("Error in object initialization", 2);
         }
     }
 }
开发者ID:Welvin,项目名称:stingle,代码行数:14,代码来源:MemcacheWrapper.class.php

示例2: 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']);
     }
 }
开发者ID:rosstuck,项目名称:SessionHandler,代码行数:17,代码来源:Memcache.php

示例3: __construct

 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']));
     }
 }
开发者ID:billge1205,项目名称:biny,代码行数:12,代码来源:TXMemcache.php

示例4: __construct

 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.
     }
 }
开发者ID:justthefish,项目名称:hesper,代码行数:14,代码来源:PeclMemcache.php

示例5: __construct

 /**
  * Конструктор
  *
  * @param array $servers
  * @param boolean $persistent
  */
 public function __construct($host, $port, $persistent = false)
 {
     if (!extension_loaded('memcache') || !class_exists('Memcache')) {
         throw new _Core_Cache_Exception('Extension "memcache" is not loaded or not up to date !');
     }
     $this->server = new Memcache();
     if ($persistent) {
         $connected = $this->server->pconnect($host, $port);
     } else {
         $connected = $this->server->connect($host, $port);
     }
     if (!$connected) {
         throw new _Core_Cache_Exception('Could not connect to memcached server on ' . $host . ':' . $port . ' !');
     }
 }
开发者ID:ru-easyfinance,项目名称:EasyFinance,代码行数:21,代码来源:Memcache.php

示例6: __construct

 public function __construct($exp = 3600)
 {
     $this->expire = $exp;
     if (defined('CACHE_DRIVER')) {
         $this->cachedriver = CACHE_DRIVER;
     }
     if ($this->cachedriver == 'memcached') {
         $mc = new Memcache();
         if ($mc->pconnect(MEMCACHE_HOSTNAME, MEMCACHE_PORT)) {
             $this->memcache = $mc;
             $this->ismemcache = true;
         }
     }
     if (!$this->ismemcache) {
         $files = glob(DIR_CACHE . 'cache.*');
         if ($files) {
             foreach ($files as $file) {
                 $time = substr(strrchr($file, '.'), 1);
                 if ($time < time()) {
                     if (file_exists($file)) {
                         @touch($file);
                         @unlink($file);
                     }
                 }
             }
         }
     }
 }
开发者ID:rb2,项目名称:ocstoreru,代码行数:28,代码来源:cache.php

示例7: _on_initialize

 /**
  * This handler completes the configuration.
  */
 public function _on_initialize()
 {
     if (array_key_exists('host', $this->_config)) {
         $this->_host = $this->_config['host'];
     }
     if (array_key_exists('port', $this->_config)) {
         $this->_port = $this->_config['port'];
     }
     // memcache does serialization automatically. no need for manual serialization
     $this->_auto_serialize = false;
     // Open the persistant connection.
     if (is_null(self::$memcache)) {
         self::$memcache = new Memcache();
         try {
             self::$memcache_operational = @self::$memcache->pconnect($this->_host, $this->_port);
         } catch (Exception $e) {
             // Memcache connection failed
             if ($this->_abort_on_fail) {
                 debug_add("Failed to connect to {$this->_host}:{$this->_port}. " . $e->getMessage(), MIDCOM_LOG_ERROR);
                 // Abort the request
                 throw new midcom_error("Failed to connect to {$this->_host}:{$this->_port}.");
             }
             // Otherwise we just skip caching
             debug_add("memcache handler: Failed to connect to {$this->_host}:{$this->_port}. " . $e->getMessage() . ". Serving this request without cache.", MIDCOM_LOG_ERROR);
             self::$memcache_operational = false;
         }
     }
 }
开发者ID:nemein,项目名称:openpsa,代码行数:31,代码来源:memcached.php

示例8: Memcache

 function _init_connection()
 {
     if (!class_exists('Memcache')) {
         return false;
     }
     $memcache_connection = new Memcache();
     $server_list = explode(',', AMP_SYSTEM_MEMCACHE_SERVER);
     $primary_server = array_shift($server_list);
     $result = $memcache_connection->pconnect($primary_server, AMP_SYSTEM_MEMCACHE_PORT);
     if (count($server_list)) {
         foreach ($server_list as $additional_server) {
             $result = $memcache_connection->addServer($additional_server, AMP_SYSTEM_MEMCACHE_PORT) || $result;
         }
     }
     if ($result) {
         $this->set_connection($memcache_connection);
     } else {
         trigger_error(sprintf(AMP_TEXT_ERROR_CACHE_REQUEST_FAILED, 'Memcache', 'connect', 'Request: ' . $_SERVER['REQUEST_URI']));
         $result = $this->_restart_memcached();
         //try again
         if ($result) {
             $this->set_connection($memcache_connection);
         }
     }
     return $result;
 }
开发者ID:radicaldesigns,项目名称:amp,代码行数:26,代码来源:Memcache.php

示例9: elggcache_cacheinit

function elggcache_cacheinit()
{
    global $CFG, $messages;
    //memcache_debug(true);
    if (!empty($CFG->elggcache_enabled)) {
        static $memcacheconn;
        //var_dump($memcacheconn);
        if (!isset($memcacheconn)) {
            if (!empty($CFG->elggcache_debug)) {
                $messages[] = 'connecting to memcache<br />';
            }
            $memcacheconn = new Memcache();
            $memcacheconn->pconnect($CFG->elggcache_memcache_host, $CFG->elggcache_memcache_port);
        }
        //var_dump($memcacheconn);
        if (empty($memcacheconn) || !is_resource($memcacheconn->connection)) {
            $CFG->elggcache_enabled = false;
            if (!empty($CFG->elggcache_debug)) {
                $messages[] = 'failed connect to memcache<br />';
            }
        }
    } else {
        $memcacheconn = false;
    }
    //$stats = $memcacheconn->getExtendedStats();
    //var_dump($stats);
    //var_dump($memcacheconn);
    return $memcacheconn;
}
开发者ID:BackupTheBerlios,项目名称:tulipan-svn,代码行数:29,代码来源:engine.memcache.php

示例10: __construct

 public function __construct()
 {
     $host = '127.0.0.1';
     $port = 11211;
     $memcache = new \Memcache();
     $memcache->pconnect($host, $port);
     $this->memcache = $memcache;
 }
开发者ID:aiyeyun,项目名称:aiyeyun,代码行数:8,代码来源:Memcache.php

示例11: __construct

 /**
  * {@inheritDoc}
  */
 public function __construct($name)
 {
     $this->prefix = $name;
     if (!self::$memcache) {
         self::$memcache = new Memcache();
         $host = Config::get('cache_host');
         $port = Config::get('cache_port');
         if (Config::get('cache_memcache_pconnect')) {
             if (!@self::$memcache->pconnect($host, $port)) {
                 throw new CacheException("Couldn't connect to memcache server");
             }
         } else {
             if (!@self::$memcache->connect($host, $port)) {
                 throw new CacheException("Couldn't connect to memcache server");
             }
         }
     }
 }
开发者ID:newlongwhitecloudy,项目名称:OpenConext-engineblock,代码行数:21,代码来源:CacheStorageMemcache.php

示例12: isAvailable

 /**
  * Detect if backend is available
  * @return bool
  */
 public static function isAvailable()
 {
     if (!extension_loaded('memcache')) {
         return false;
     }
     if (self::$memcache) {
         return true;
     }
     $serverList = [['unix:///tmp/memcache', 0], ['127.0.0.1', 11211]];
     self::$memcache = new \MemCache();
     foreach ($serverList as $serv) {
         if (@self::$memcache->pconnect($serv[0], $serv[1])) {
             self::$server = $serv[0];
             self::$port = $serv[1];
             return true;
         }
     }
     return false;
 }
开发者ID:difra-org,项目名称:difra,代码行数:23,代码来源:MemCache.php

示例13: enableMemcache

 public function enableMemcache()
 {
     $this->memcacheConfig = ConfigManager::getConfig("Db", "Memcache")->AuxConfig;
     if ($this->memcacheConfig->enabled) {
         $memcache = new Memcache();
         if ($memcache->pconnect($this->memcacheConfig->host, $this->memcacheConfig->port)) {
             Minify::setCache(new Minify_Cache_Memcache($memcache));
         }
     }
 }
开发者ID:Welvin,项目名称:stingle,代码行数:10,代码来源:MinifyWrapper.class.php

示例14: getConnection

 /**
  * Create the Memcache connection
  *
  * @return  void
  *
  * @since   11.1
  * @throws  RuntimeException
  */
 protected function getConnection()
 {
     if (!static::isSupported()) {
         throw new RuntimeException('Memcache Extension is not available');
     }
     $config = JFactory::getConfig();
     $host = $config->get('memcache_server_host', 'localhost');
     $port = $config->get('memcache_server_port', 11211);
     // Create the memcache connection
     static::$_db = new Memcache();
     if ($config->get('memcache_persist', true)) {
         $result = @static::$_db->pconnect($host, $port);
     } else {
         $result = @static::$_db->connect($host, $port);
     }
     if (!$result) {
         // Null out the connection to inform the constructor it will need to attempt to connect if this class is instantiated again
         static::$_db = null;
         throw new JCacheExceptionConnecting('Could not connect to memcache server');
     }
 }
开发者ID:joomla-projects,项目名称:media-manager-improvement,代码行数:29,代码来源:memcache.php

示例15: cache_memcache

function cache_memcache()
{
    global $_W;
    static $memcacheobj;
    if (!extension_loaded('memcache')) {
        return error(1, 'Class Memcache is not found');
    }
    if (empty($memcacheobj)) {
        $config = $_W['config']['setting']['memcache'];
        $memcacheobj = new Memcache();
        if ($config['pconnect']) {
            $connect = $memcacheobj->pconnect($config['server'], $config['port']);
        } else {
            $connect = $memcacheobj->connect($config['server'], $config['port']);
        }
    }
    return $memcacheobj;
}
开发者ID:ChainBoy,项目名称:wxfx,代码行数:18,代码来源:cache.memcache.func.php


注:本文中的Memcache::pconnect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。