vsavritsky / bitrix-rest-api-cache
关于此包最新版本(0.1.4)的许可信息不可用。
基于API的缓存应用程序库
0.1.4
2023-10-08 14:09 UTC
Requires
- php: >=7.4
- predis/predis: ^1.1
- slim/psr7: dev-master
README
要将Redis缓存连接到Bitrix,需要
- 安装依赖 composer require vsavritsky/bitrix-rest-api-cache
- 在文件 bitrix/php_interface/dbconn.php 中连接自动加载器 require($_SERVER['DOCUMENT_ROOT'] . "/local/php_interface/vendor/autoload.php");
- 在文件 bitrix/.settings_extra.php 中添加Redis连接设置(示例在 examples 文件夹中)
- 在控制器中调用缓存
$cache = new PhpCache($this->getRequest());
$cacheResult = $cache->init();
if (!$cacheResult) {
// кешируемый вызов
// $result = ['test' => 1];
if ($result) {
$cache->addTag('test');
$cacheResult = new TestResponse();
$cache->cache($result);
}
}