【发布时间】:2019-02-22 23:04:59
【问题描述】:
内容管理框架 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和http://php.net/manual/de/apcuiterator.construct.php)
我需要如何编辑这个构造函数才能让我的 CMF 与 APCu 作为缓存引擎一起工作?
【问题讨论】:
标签: php modx apc modx-revolution apcu