src/Queries/BaseQuery.php
protected function rememberInCache($key, $minutes, Closure $callback)
    {
        $minutes = (double) $minutes;
        if ($minutes <= 0) {
            return $callback();
        }

        $cache = Cache::createInstance();
        if ($cache->initCache($minutes * 60, $key, '/bitrix-models')) {
            $vars = $cache->getVars();
            return !empty($vars['isCollection']) ? new Collection($vars['cache']) : $vars['cache'];
        }

        $cache->startDataCache();
        $result = $callback();

        // Bitrix cache is bad for storing collections. Let's convert it to array.
        $isCollection = $result instanceof Collection;
        if ($isCollection) {
            $result = $result->all();
        }

        $cache->endDataCache(['cache' => $result, 'isCollection' => $isCollection]);

        return $isCollection ? new Collection($result) : $result;
    }
protected function rememberInCache($key, $minutes, Closure $callback)
    {
        $minutes = (double) $minutes;
        if ($minutes <= 0) {
            return $callback();
        }

        $cache = Cache::createInstance();
        if ($cache->initCache($minutes * 60, $key, '/bitrix-models')) {
            $vars = $cache->getVars();
            return !empty($vars['isCollection']) ? new Collection($vars['cache']) : $vars['cache'];
        }

        $cache->startDataCache();
        $result = $callback();

        // Bitrix cache is bad for storing collections. Let's convert it to array.
        $isCollection = $result instanceof Collection;
        if ($isCollection) {
            $result = $result->all();
        }

        $cache->endDataCache(['cache' => $result, 'isCollection' => $isCollection]);

        return $isCollection ? new Collection($result) : $result;
    }
protected function rememberInCache ( $ key , $ minutes , Closure $ callback ) { $ minutes = ( double ) $ minutes ; if ( $ minutes <= 0 ) { return $ callback ( ) ; } $ cache = Cache :: createInstance ( ) ; if ( $ cache -> initCache ( $ minutes * 60 , $ key , '/bitrix-models' ) ) { $ vars = $ cache -> getVars ( ) ; return ! empty ( $ vars [ 'isCollection' ] ) ? new Collection ( $ vars [ 'cache' ] ) : $ vars [ 'cache' ] ; } $ cache -> startDataCache ( ) ; $ result = $ callback ( ) ; // Bitrix cache is bad for storing collections. Let's convert it to array. $ isCollection = $ result instanceof Collection ; if ( $ isCollection ) { $ result = $ result -> all ( ) ; } $ cache -> endDataCache ( [ 'cache' => $ result , 'isCollection' => $ isCollection ] ) ; return $ isCollection ? new Collection ( $ result ) : $ result ; }
Store closure's result in the cache for a given number of minutes.

@param string $key
@param double $minutes
@param Closure $callback
@return mixed
Store closure s result in the cache for a given number of minutes .