CakePHP 3 cell_cache配置

时间:2015-03-30 13:22:20

标签: caching cakephp-3.0

我有以下代码:

$cell = $this->cell('Admin/Notifications', ['since' => $user['last_login']], [
    'cache' => ['config' => 'cell_cache', 'key' => 'notifications_' . $user['id']]
]);
echo $cell;

我用它来调用CakePHP 3中的一个单元格并同时缓存它。但它输出一个错误:

Warning (512): Could not render cell - The "cell_cache" cache configuration does not exist. [CORE\src\View\Cell.php, line 244]

我错过了什么?我已经搜索了手册但是没有找到我是否必须声明这个配置以及在哪里。

先谢谢你的回答。

1 个答案:

答案 0 :(得分:1)

我找到了答案。在" config / app.php"我已将以下代码添加到"缓存"适配器:

'cell_cache' => [
    'className' => 'File',
    'prefix' => 'myapp_cell_cache_',
    'path' => CACHE . 'persistent/',
    'serialize' => true,
    'duration' => '+10 minutes',
 ],

所以我错过了配置,但是没有在文档中指定。我认为应该补充一下。