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


PHP Memcached::resetServerList方法代码示例

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


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

示例1: getConnection

 /**
  * Create the Memcached connection
  *
  * @return  void
  *
  * @since   12.1
  * @throws  RuntimeException
  */
 protected function getConnection()
 {
     if (!static::isSupported()) {
         throw new RuntimeException('Memcached Extension is not available');
     }
     $config = JFactory::getConfig();
     $host = $config->get('memcached_server_host', 'localhost');
     $port = $config->get('memcached_server_port', 11211);
     // Create the memcached connection
     if ($config->get('memcached_persist', true)) {
         static::$_db = new Memcached($this->_hash);
         $servers = static::$_db->getServerList();
         if ($servers && ($servers[0]['host'] != $host || $servers[0]['port'] != $port)) {
             static::$_db->resetServerList();
             $servers = array();
         }
         if (!$servers) {
             static::$_db->addServer($host, $port);
         }
     } else {
         static::$_db = new Memcached();
         static::$_db->addServer($host, $port);
     }
     static::$_db->setOption(Memcached::OPT_COMPRESSION, $this->_compress);
     $stats = static::$_db->getStats();
     $result = !empty($stats["{$host}:{$port}"]) && $stats["{$host}:{$port}"]['pid'] > 0;
     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 memcached server');
     }
 }
开发者ID:iFactoryDigital,项目名称:gympieradiology,代码行数:40,代码来源:memcached.php

示例2: __destruct

 public function __destruct()
 {
     if ($this->instance) {
         $this->instance->resetServerList();
         unset($this->instance);
     }
 }
开发者ID:ovr,项目名称:cacher,代码行数:7,代码来源:Memcached.php

示例3: setMemcached

 /**
  * @param \Memcached|null $memcached
  */
 public function setMemcached($memcached = null)
 {
     if ($memcached) {
         $this->memcached = $memcached;
     }
     if ($this->memcached) {
         $this->memcached->resetServerList();
         $this->memcached->addServer($this->server, $this->port);
     }
 }
开发者ID:fustundag,项目名称:awscw-custom-metrics,代码行数:13,代码来源:MemcachedCheck.php

示例4: maybeAddServerConnections

 /**
  * Maybe add server connections.
  *
  * @since 151216 Memcached utilities.
  */
 protected function maybeAddServerConnections()
 {
     if (!$this->Pool) {
         return;
         // Not possible.
     }
     if ($this->serversDiffer()) {
         $this->Pool->quit();
         $this->Pool->resetServerList();
         $this->Pool->addServers($this->servers);
     }
 }
开发者ID:websharks,项目名称:core,代码行数:17,代码来源:Memcache.php

示例5: testDelete

 public function testDelete()
 {
     $this->storage->get('oldkey');
     $this->assertArrayHasKey('oldkey', $this->storage->getCasArray(), 'Cas array has not key "oldkey"!');
     $this->assertEquals(0, $this->storage->delete('oldkey'), 'Delete failed!');
     $this->assertArrayNotHasKey('oldkey', $this->storage->getCasArray(), 'Cas array has key "oldkey"!');
     try {
         self::$memcached->resetServerList();
         $this->storage->delete('oldkey');
     } catch (StorageException $e) {
         if (count(self::$memcached->getServerList()) == 0) {
             self::$memcached->addServers(array(array(MEMCACHED_HOST, MEMCACHED_PORT)));
         }
         return;
     }
     $this->fail('Storage delete exception test failed');
 }
开发者ID:fustundag,项目名称:tokenbucket,代码行数:17,代码来源:MemcachedTest.php

示例6: getStats

 public function getStats()
 {
     $stats = $this->handler->getStats();
     $servers = $this->servers;
     foreach ($stats as $key => $stat) {
         if ($stat['pid'] === -1) {
             //移除不可用的server
             unset($servers[$key]);
         }
     }
     //没有可用的server
     if (empty($servers)) {
         $this->isConnected = false;
         return false;
     } else {
         $this->handler->resetServerList();
         $status = $this->handler->addServers(array_values($servers));
         if ($status) {
             $this->isConnected = true;
         }
         return $status;
     }
 }
开发者ID:iliubang,项目名称:LinkCache,代码行数:23,代码来源:Memcached.php

示例7: Memcached

<?php

$mem = new Memcached();
$mem->addServer("localhost", 1234);
var_dump(count($mem->getServerList()));
$mem->resetServerList();
var_dump($mem->getServerList());
开发者ID:badlamer,项目名称:hhvm,代码行数:7,代码来源:resetServerList.php


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