public function setConfig($config) { parent::setConfig($config); $this->table = $this->getConfig('table-name', '', 'cache', $config); $this->keyField = $this->getConfig('field-key', '', 'key', $config); $this->valueField = $this->getConfig('field-value', '', 'value', $config); $this->expireField = $this->getConfig('field-expire', '', 'expire', $config); }
public function setConfig($config = array()) { if (!$config) { return false; } parent::setConfig($config); $this->authUser = $this->getConfig('user'); $this->authPwd = $this->getConfig('pwd'); }
public function setConfig($config) { parent::setConfig($config); $auth = $this->getConfig('auth', '', ''); if ($auth && true !== $this->redis->auth($auth)) { throw new WindCacheException('Authenticate the redis connection error'); } $servers = $this->getConfig('servers', '', array()); $defaultServer = array('host' => '', 'port' => 6379, 'timeout' => 0, 'pconn' => false, 'persistent_id' => ''); foreach ((array) $servers as $server) { if (!is_array($server)) { throw new WindCacheException('The redis config is incorrect'); } $args = array_merge($defaultServer, $server); if (!isset($server['host'])) { throw new WindCacheException('The redis server ip address is not exist'); } $method = $args['pconn'] === true ? 'pconnect' : 'connect'; $m_args = array($args['host'], $args['port'], $args['timeout']); //如果是长链接,则会存在一个长链接的ID号 $args['pconn'] === true && $args['persistent_id'] && ($m_args[] = $args['persistent_id']); call_user_func_array(array($this->redis, $method), $m_args); } }
public function setConfig($config) { parent::setConfig($config); $this->setCacheDir($this->getConfig('dir')); $this->setCacheFileSuffix($this->getConfig('suffix', '', 'txt')); $this->setCacheDirectoryLevel($this->getConfig('dir-level', '', 0)); }
public function setConfig($config) { parent::setConfig($config); $servers = $this->getConfig('servers', '', array()); foreach ((array) $servers as $server) { if (!is_array($server)) { throw new WindException('The memcache config is incorrect'); } if (!isset($server['host'])) { throw new WindException('The memcache server ip address is not exist'); } if (!isset($server['port'])) { throw new WindException('The memcache server port is not exist'); } $this->memcache->addServer($server['host'], $server['port'], isset($server['weight']) ? $server['weight'] : null); } }
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']); } }