lluiscamino / fast-cache
PHP应用简单缓存系统
1.0.0
2020-02-12 21:18 UTC
This package is auto-updated.
Last update: 2024-09-13 07:28:27 UTC
README
PHP应用简单缓存系统。
安装
使用以下命令通过Composer安装
composer require lluiscamino/fast-cache
用法
$cache = new FastCache(21600); // Cache lifetime in seconds $cache->start(); echo "Hola!"; // Display content $cache->end();
当用户首次访问您的网站时,将创建一个页面缓存版本并在指定时间内为后续请求提供服务。
如果出于某种原因您不希望当前内容被保存,可以使用 $cache->end(false); 并将内容不会进行缓存。
除了时间外,您还可以在构造函数中指定两个其他参数
__construct(int $time, string $file = null, string $dir = '')
string $file:标识被缓存页面的(file.php)文件的名称。使用此选项创建相同页面的不同缓存版本。留空以自动从创建对象的文件中自动选择文件。string $dir:缓存文件将保存的子目录。
配置
FastCache::$path = 'custom-dir'; // Cache files directory FastCache::$announce = false; // Disable "Serving cached file fromServing cached file from..." comment