m-shimao / find-in-file-cache
CakePHP 的文件缓存插件
dev-master
2017-01-31 05:04 UTC
Requires
- php: >=5.5
- cakephp/cakephp: ~3.3
Requires (Dev)
This package is not auto-updated.
Last update: 2024-09-28 19:58:21 UTC
README
它是用来做什么的?
它是静态模型的模型行为。如果您想为静态模型使用文件缓存,此插件易于使用。
安装
您可以使用 composer 将此插件安装到您的 CakePHP 应用程序中。安装 composer 包的推荐方法是
composer require m-shimao/find-in-file-cache dev-master
同时,别忘了在您的 bootstrap 中加载此插件
Plugin::load('FindInFileCache'); // or Plugin::loadAll();
使用方法
表格
<?php
class CategoriesTable extends Table
{
public function initialize(array $config)
{
$this->addBehavior('FindInFileCache.FindInFileCache');
}
}
配置
默认设置如下。
'className' => 'File',↲
'prefix' => 'myapp_cake_static_record_',↲
'path' => CACHE . 'static_records/',↲
'duration' => '+15 minutes',↲
'mask' => 0666,↲
如果您使用原始设置,请编辑 app.php 中的缓存部分。
<?php
return [
...
'Cache' => [
...
'find-in-file' => [
'className' => 'File',↲
<type your setting>
],
...
],
...
];