|
发表于 2013-9-6 18:54:27
|
显示全部楼层
发现了 CodeIgniter 缓存类的 BUG 貌似很严重的BUG
楼主啊.... 你写的这个有问题啊......
看这里, 这里传了 4个参数 呃
$result = $this->_memcached->replace($id, array($data, time(), $ttl), 0, $ttl);
而 MEMCACHED 提供的 API 是只能传三个参数
public bool Memcached::replace ( string $key , mixed $value [, int $expiration ] )
PHP复制代码
/**
* Replace the cache
*
* @param string unique key
* @param mixed data to store
* @param int length of time (in seconds) the cache is valid
* - Default is 60 seconds
* @return boolean true on success/false on failure
*/
public function replace ($id, $data, $ttl = 60)
{
$result = $this->_memcached ->replace($id, array($data, time(), $ttl), 0, $ttl);
if($result === FALSE)
{
$result = $this->save($id, $data, $ttl);
}
return $result;
}
复制代码
下面这里 _memcached 它是new 的
$this->_memcached = new Memcached();
PHP复制代码
/**
* Setup memcached.
*/
private function _setup_memcached ()
{
// Try to load memcached server info from the config file.
$CI =& get_instance ();
if ($CI->config->load('memcached', TRUE, TRUE))
{
if (is_array($CI->config->config['memcached']))
{
$this->_memcache_conf = NULL;
foreach ($CI->config->config['memcached'] as $name => $conf)
{
$this->_memcache_conf [$name] = $conf;
}
}
}
$this->_memcached = new Memcached ();
foreach ($this->_memcache_conf as $name => $cache_server)
{
if ( ! array_key_exists('hostname', $cache_server))
{
$cache_server['hostname'] = $this->_default_options ['default_host'];
}
if ( ! array_key_exists('port', $cache_server))
{
$cache_server['port'] = $this->_default_options ['default_port'];
}
if ( ! array_key_exists('weight', $cache_server))
{
$cache_server['weight'] = $this->_default_options ['default_weight'];
}
$this->_memcached ->addServer(
$cache_server['hostname'], $cache_server['port'], $cache_server['weight']
);
}
}
复制代码
居然 这么 粗心 ..... 调了我一个下午啊....... CI 那个也不是很完善... system 里报的错误 居然...... 唉…………………………………………………………………… |
-
|