Server IP : 85.193.89.191 / Your IP : 18.188.29.0 Web Server : Apache System : Linux 956367-cx40159.tmweb.ru 3.10.0-1160.105.1.el7.x86_64 #1 SMP Thu Dec 7 15:39:45 UTC 2023 x86_64 User : bitrix ( 600) PHP Version : 8.1.27 Disable Function : NONE MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/bitrix/www/bitrix/modules/b24connector/lib/ |
Upload File : |
<?php namespace Bitrix\B24Connector; use Bitrix\Main\Application; /** * Simple wrapper around data cache * @internal * @package Bitrix\B24Connector */ final class Cache { const CACHE_ROOT = '/b24connector'; /** * Returns data from cache if it's valid. Stores data returned by $callback in cache and returns them otherwise. * @param string $cacheId * @param int $ttl * @param callable $callback * @return mixed */ public static function remember(string $cacheId, int $ttl, callable $callback) { $cachePath = self::CACHE_ROOT . '/' . $cacheId; $manager = Application::getInstance()->getCache(); if ($manager->initCache($ttl, $cacheId, $cachePath)) { $cached = $manager->getVars(); return $cached['PROXY']; } else { $result = $callback(); $manager->startDataCache(); $manager->endDataCache(['PROXY' => $result]); return $result; } } }