CakePHP 3 cell_cache 配置
CakePHP 3 cell_cache configuration
我有以下代码:
$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]
我错过了什么?我已经搜索了手册,但没有找到我是否必须声明此配置以及在哪里。
预先感谢您的回答。
我找到了答案。在 "config/app.php" 中,我将以下代码添加到 "Cache" 适配器中:
'cell_cache' => [
'className' => 'File',
'prefix' => 'myapp_cell_cache_',
'path' => CACHE . 'persistent/',
'serialize' => true,
'duration' => '+10 minutes',
],
所以我错过了配置,但文档中没有指定。我觉得应该加上。
我有以下代码:
$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]
我错过了什么?我已经搜索了手册,但没有找到我是否必须声明此配置以及在哪里。
预先感谢您的回答。
我找到了答案。在 "config/app.php" 中,我将以下代码添加到 "Cache" 适配器中:
'cell_cache' => [
'className' => 'File',
'prefix' => 'myapp_cell_cache_',
'path' => CACHE . 'persistent/',
'serialize' => true,
'duration' => '+10 minutes',
],
所以我错过了配置,但文档中没有指定。我觉得应该加上。