vsavritsky/bitrix-rest-api-cache

关于此包最新版本(0.1.4)的许可信息不可用。

基于API的缓存应用程序库

0.1.4 2023-10-08 14:09 UTC

This package is auto-updated.

Last update: 2024-09-08 15:55:53 UTC


README

要将Redis缓存连接到Bitrix,需要

  1. 安装依赖 composer require vsavritsky/bitrix-rest-api-cache
  2. 在文件 bitrix/php_interface/dbconn.php 中连接自动加载器 require($_SERVER['DOCUMENT_ROOT'] . "/local/php_interface/vendor/autoload.php");
  3. 在文件 bitrix/.settings_extra.php 中添加Redis连接设置(示例在 examples 文件夹中)
  4. 在控制器中调用缓存
$cache = new PhpCache($this->getRequest());
$cacheResult = $cache->init();
if (!$cacheResult) {
    // кешируемый вызов
    // $result = ['test' => 1];
    if ($result) {
        $cache->addTag('test');
        $cacheResult = new TestResponse();
        $cache->cache($result);
    }
}