内容管理框架MODX提供了将APC用作缓存引擎的选项。我发现我可能能够将其迁移到APCU。
我复制并编辑了所有代码,以便我有第二个选项将APCU作为缓存引擎。正如我的PHP技能在过去几年中所描述的那样,我正在为重写构造函数的正确方法而苦苦挣扎。
原始代码就是这样:
class xPDOAPCCache extends xPDOCache {
public function __construct(& $xpdo, $options = array()) {
parent :: __construct($xpdo, $options);
if (function_exists('apc_exists')) {
$this->initialized = true;
} else {
$this->xpdo->log(xPDO::LOG_LEVEL_ERROR, "xPDOAPCCache[{$this->key}]: Error creating APC cache provider; xPDOAPCCache requires the APC extension for PHP, version 2.0.0 or later.");
}
}
[...]
我重写了这样的:
class xPDOAPCuCache extends xPDOCache {
public function __construct(& $xpdo, $options = array()) {
parent :: __construct($xpdo, $options);
if (function_exists('apcu_exists')) {
$this->initialized = true;
} else {
$this->xpdo->log(xPDO::LOG_LEVEL_ERROR, "xPDOAPCuCache[{$this->key}]: Error creating APCu cache provider; xPDOAPCuCache requires the APCu extension for PHP.");
}
}
[...]
无法使用,因为APCU不采用与APC相同的参数。(请参阅http://php.net/manual/de/apciterator.construct.php and http://php.net/manual/manual/de/apcuiterator.consstruct.php)
)我需要编辑此文件以使我的CMF用APCU作为缓存引擎工作?
您的代码示例似乎根本没有引用apciterator?因此,很难说会发生什么变化。
我建议您查看APCU_BC,该apcu_bc提供了与APCU顶部的APC API兼容层。我不确定迭代器,但是我已经成功使用了此软件包了一段时间,直到我逐渐迁移到本机APCU API上。