- 语言
- 英文 (English)
此插件使用 Credis 与自定义缓存提供程序进行 Redis (基于 Cm_Cache_Backend_Redis)。为获得最佳性能,请安装php扩展:phpredis
故障排除
请注意,Redis对虚拟环境中的延迟非常敏感。如果遇到重复的连接失败或协议错误,请禁用所有Redis Persistence选项。
congfig配置
或者
高效
Zend组件支持Redis Sentinel支持的主/从设置。 它不支持Redis多主集群。
此外,此附加组件实现了在论坛中缓存线程计数。
故障排除
请注意,Redis对虚拟环境中的延迟非常敏感。如果遇到重复的连接失败或协议错误,请禁用所有Redis Persistence选项。
congfig配置
PHP:
$config['cache']['enabled'] = true;
$config['cache']['sessions'] = true;
$config['cache']['namespace'] = 'xf_';
$config['cache']['provider'] = 'SV\RedisCache\Redis';
$config['cache']['config'] = array(
'server' => '127.0.0.1',
'port' => 6379,
'connect_retries' => 2,
'compress_data' => 6,
'use_lua' => true,
'serializer' => 'igbinary'
);
或者
PHP:
$config['cache']['enabled'] = true;
$config['cache']['namespace'] = 'xf_';
$config['cache']['sessions'] = true;
$config['cache']['config'] = [
'host' => '127.0.0.1'
];
$config['cache']['provider'] = function(array $config)
{
if (!class_exists('Redis'))
{
throw new \LogicException("Cannot load Redis cache provider without Redis");
}
$config = array_replace([
'host' => '',
'port' => 6379,
'timeout' => 0.0,
'password' => '',
'database' => 0,
'persistent' => false,
'persistent_id' => ''
], $config);
$r = new \Redis();
if ($config['persistent'])
{
$r->pconnect($config['host'], $config['port'], $config['timeout'], $config['persistent_id']);
}
else
{
$r->connect($config['host'], $config['port'], $config['timeout']);
}
if ($config['password'])
{
$r->auth($config['password']);
}
if ($config['database'])
{
$r->select($config['database']);
}
$cache = new \Doctrine\Common\Cache\RedisCache();
$cache->setRedis($r);
return $cache;
};
高效
Zend组件支持Redis Sentinel支持的主/从设置。 它不支持Redis多主集群。
此外,此附加组件实现了在论坛中缓存线程计数。