Пример #1
0
 public function setConfig($config)
 {
     parent::setConfig($config);
     $servers = $this->getConfig('servers', '', array());
     foreach ((array) $servers as $server) {
         if (!is_array($server)) {
             throw new WindCacheException('[cache.strategy.WindMemCached.setConfig] The memcache config is incorrect');
         }
         if (!isset($server['host'])) {
             throw new WindCacheException('[cache.strategy.WindMemCached.setConfig] The memcache server ip address is not exist');
         }
         if (!isset($server['port'])) {
             throw new WindCacheException('[cache.strategy.WindMemCached.setConfig] The memcache server port is not exist');
         }
         $this->memcache->addServer($server['host'], $server['port'], isset($server['weight']) ? $server['weight'] : null);
     }
 }
Пример #2
0
 public function setConfig($config)
 {
     parent::setConfig($config);
     $this->compress = $this->getConfig('compress', '', '0');
     $servers = $this->getConfig('servers', '', array());
     $defaultServer = array('host' => '', 'port' => '', 'pconn' => true, 'weight' => 1, 'timeout' => 1, 'retry' => 15, 'status' => true, 'fcallback' => null);
     foreach ((array) $servers as $server) {
         if (!is_array($server)) {
             throw new WindCacheException('[cache.strategy.WindMemCache.setConfig] The memcache config is incorrect');
         }
         $args = array_merge($defaultServer, $server);
         if (empty($server['host'])) {
             throw new WindCacheException('[cache.strategy.WindMemCache.setConfig] The memcache server ip address is not exist');
         }
         if (empty($server['port'])) {
             throw new WindCacheException('[cache.strategy.WindMemCache.setConfig] The memcache server port is not exist');
         }
         $this->memcache->addServer($args['host'], $args['port'], $args['pconn'], $args['weight'], $args['timeout'], $args['retry'], $args['status'], $args['fcallback']);
     }
 }