wordpress启用memcached加速wordpress在快速搭建服务器环境中有说到,加速效果明显。
但是直接上传上去发现报如下错误:
Notice: Undefined offset: 1 in ……/wp-content/object-cache.php on line 374
wordpress开启调试模式,在wp-config.php文件中
[code]define(‘WP_DEBUG’, true);[/code]
解决方法:
打开object-cache.php文件,查找127.0.0.1,对应的函数如下:
[code]
function WP_Object_Cache() {
global $memcached_servers;
if ( isset($memcached_servers) )
$buckets = $memcached_servers;
else
$buckets = array(‘127.0.0.1′);
reset($buckets);
if ( is_int( key($buckets) ) )
$buckets = array(‘default’ => $buckets);
foreach ( $buckets as $bucket => $servers) {
$this->mc[$bucket] = new Memcache();
foreach ( $servers as $server ) {
list ( $node, $port ) = explode(‘:’, $server);
if ( !$port )
$port = ini_get(‘memcache.default_port’);
$port = intval($port);
if ( !$port )
$port = 11211;
$this->mc[$bucket]->addServer($node, $port, true, 1, 1, 15, true, array($this, ‘failure_callback’));
$this->mc[$bucket]->setCompressThreshold(20000, 0.2);
}
}
[/code]
$buckets = array('127.0.0.1');这句修改成:
[code]$buckets = array(‘127.0.0.1:11211′);
[/code]
问题解决。