Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
compilecache.php
1<?php
9namespace Bitrix\Main\Routing;
10
12
18{
23 public static function handle($files, $router)
24 {
25 $cacheKeyElements = [];
26
27 foreach ($files as $file)
28 {
29 $cacheKeyElements[] = $file.':'.filemtime($file);
30 }
31
32 $cacheKey = 'compiled_'.md5(join(',', $cacheKeyElements));
33 $cacheDir = 'routing';
34
35 $cache = Cache::createInstance();
36
37 if ($cache->initCache(3600*24*365, $cacheKey, $cacheDir))
38 {
39 $cacheData = $cache->getVars();
40 }
41
42 if (empty($cacheData))
43 {
44 // compile all the routes
45 $cacheData = [];
46
47 foreach ($router->getRoutes() as $k => $route)
48 {
49 $cacheData[$k] = $route->getCompileCache();
50 }
51
52 if ($cache->startDataCache())
53 {
54 $cache->endDataCache($cacheData);
55 }
56 }
57 else
58 {
59 // compile all the routes from cache
60 foreach ($router->getRoutes() as $k => $route)
61 {
62 $route->compileFromCache($cacheData[$k]);
63 }
64 }
65 }
66}
static handle($files, $router)