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


PHP resource::addServer方法代码示例

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


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

示例1: array

 /**
  * Constructor
  *
  * @access protected
  * @param array $options optional parameters
  */
 function __construct($options = array())
 {
     if (!$this->test()) {
         return JError::raiseError(404, "The memcache extension is not available");
     }
     parent::__construct($options);
     $config =& JFactory::getConfig();
     $params = $config->getValue('config.memcache_settings');
     if (!is_array($params)) {
         $params = unserialize(stripslashes($params));
     }
     if (!$params) {
         $params = array();
     }
     $this->_compress = isset($params['compression']) ? $params['compression'] : 0;
     $this->_persistent = isset($params['persistent']) ? $params['persistent'] : false;
     // This will be an array of loveliness
     $this->_servers = isset($params['servers']) ? $params['servers'] : array();
     // Create the memcache connection
     $this->_db = new Memcache();
     for ($i = 0, $n = count($this->_servers); $i < $n; $i++) {
         $server = $this->_servers[$i];
         $this->_db->addServer($server['host'], $server['port'], $this->_persistent);
     }
     // Get the site hash
     $this->_hash = $config->getValue('config.secret');
 }
开发者ID:Fellah,项目名称:govnobaki,代码行数:33,代码来源:memcache.php

示例2: open

 /**
  * Open the SessionHandler backend.
  *
  * @param   string  $save_path     The path to the session object.
  * @param   string  $session_name  The name of the session.
  *
  * @return  boolean  True on success, false otherwise.
  *
  * @since   11.1
  */
 public function open($save_path, $session_name)
 {
     $this->_db = new Memcached();
     for ($i = 0, $n = count($this->_servers); $i < $n; $i++) {
         $server = $this->_servers[$i];
         $this->_db->addServer($server['host'], $server['port'], $this->_persistent);
     }
     return true;
 }
开发者ID:nogsus,项目名称:joomla-platform,代码行数:19,代码来源:memcached.php

示例3: __construct

 /**
  * Initialise this new cell collection
  *
  * @param    PHPExcel_Worksheet $parent The worksheet for this cell collection
  * @param                       array   of mixed        $arguments    Additional initialisation arguments
  */
 public function __construct(PHPExcel_Worksheet $parent, $arguments)
 {
     $memcacheServer = isset($arguments['memcacheServer']) ? $arguments['memcacheServer'] : 'localhost';
     $memcachePort = isset($arguments['memcachePort']) ? $arguments['memcachePort'] : 11211;
     $cacheTime = isset($arguments['cacheTime']) ? $arguments['cacheTime'] : 600;
     if (is_null($this->_cachePrefix)) {
         $baseUnique = $this->_getUniqueID();
         $this->_cachePrefix = substr(md5($baseUnique), 0, 8) . '.';
         //	Set a new Memcache object and connect to the Memcache server
         $this->_memcache = new Memcache();
         if (!$this->_memcache->addServer($memcacheServer, $memcachePort, false, 50, 5, 5, true, array($this, 'failureCallback'))) {
             throw new PHPExcel_Exception('Could not connect to MemCache server at ' . $memcacheServer . ':' . $memcachePort);
         }
         $this->_cacheTime = $cacheTime;
         parent::__construct($parent);
     }
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:23,代码来源:Memcache.php

示例4: exit

 /**
  * 构造函数
  *
  * @param 缓存策略 $policy
  */
 function cache_memcached(array $policy = null)
 {
     if (!extension_loaded('memcache')) {
         exit('The memcache extension must be loaded before use!');
     }
     if (is_array($policy)) {
         $this->_default_policy = array_merge($this->_default_policy, $policy);
     }
     if (empty($this->_default_policy['servers'])) {
         $this->_default_policy['servers'][] = $this->_default_server;
     }
     $this->_conn = new Memcache();
     foreach ($this->_default_policy['servers'] as $server) {
         $result = $this->_conn->addServer($server['host'], $server['port'], $this->_default_policy['persistent']);
         if (!$result) {
             exit(sprintf('Connect memcached server [%s:%s] failed!', $server['host'], $server['port']));
         }
     }
 }
开发者ID:jorkin,项目名称:meiupic,代码行数:24,代码来源:memcached.php

示例5: Memcached

 /**
  * Constructor
  *
  * @param array $config an array of configuration params
  *
  * @return \CRM_Utils_Cache_Memcached
  */
 function __construct($config)
 {
     if (isset($config['host'])) {
         $this->_host = $config['host'];
     }
     if (isset($config['port'])) {
         $this->_port = $config['port'];
     }
     if (isset($config['timeout'])) {
         $this->_timeout = $config['timeout'];
     }
     if (isset($config['prefix'])) {
         $this->_prefix = $config['prefix'];
     }
     $this->_cache = new Memcached();
     if (!$this->_cache->addServer($this->_host, $this->_port)) {
         // dont use fatal here since we can go in an infinite loop
         echo 'Could not connect to Memcached server';
         CRM_Utils_System::civiExit();
     }
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:28,代码来源:Memcached.php

示例6: _connMemcached

 /**
  * Устанавливает соединение с сервером memcached и сохраняет ресурс подключения в $this->memcached
  * Если соединение существует, то переподключения не происходит.
  * 
  * @return boolean    TRUE - соединение установлено, FALSE - не установлено
  */
 protected function _connMemcached()
 {
     if (!empty($this->memcached)) {
         return TRUE;
     }
     if (class_exists('Memcached')) {
         $this->memcached = new Memcached();
         if (count($GLOBALS['memcachedServers']) == 1) {
             if ($this->memcached->addServer($GLOBALS['memcachedServers'][0], 11211)) {
                 return TRUE;
             }
         } else {
             if (count($GLOBALS['memcachedServers']) > 1) {
                 if ($this->memcached->addServers($GLOBALS['memcachedServers'])) {
                     return FALSE;
                 }
             }
         }
     }
     return FALSE;
 }
开发者ID:Nikitian,项目名称:fl-ru-damp,代码行数:27,代码来源:DB.php


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