ogdev/bitrix-rest-api-cache

There is no license information available for the latest version (dev-master) of this package.

Библиотека для кеша приложения основенного на апи

dev-master 2025-02-18 08:42 UTC

This package is not auto-updated.

Last update: 2025-05-14 08:22:33 UTC


README

Для подключения кеша редиса к битриксу нужно:

  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 (пример в папке 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);
    }
}