Created
August 9, 2012 01:58
-
-
Save ichikaway/3300279 to your computer and use it in GitHub Desktop.
Revisions
-
ichikaway revised this gist
Aug 9, 2012 . 1 changed file with 0 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,12 +6,6 @@ index cb28f6e..c6a38c3 100644 $url += array('controller' => $params['controller'], 'plugin' => $params['plugin']); - $match = false; + $cacheKey = 'Router-' . sha1(serialize($url)); + $cacheConf = Cache::settings('_cake_route_'); -
ichikaway created this gist
Aug 9, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,51 @@ diff --git a/lib/Cake/Routing/Router.php b/lib/Cake/Routing/Router.php index cb28f6e..c6a38c3 100644 --- a/lib/Cake/Routing/Router.php +++ b/lib/Cake/Routing/Router.php @@ -810,23 +810,30 @@ class Router { $url += array('controller' => $params['controller'], 'plugin' => $params['plugin']); - $match = false; + $cacheKey = 'Router-' . sha1(serialize($url)); + $cacheConf = Cache::settings('_cake_route_'); + if( empty($cacheConf) || ($output = Cache::read($cacheKey, '_cake_route_') ) === false ){ - $match = false; + $cacheKey = 'Router-' . sha1(serialize($url)); - $match = false; + $cacheKey = 'Router-' . sha1(serialize($url)); + $cacheConf = Cache::settings('_cake_route_'); + if( empty($cacheConf) || ($output = Cache::read($cacheKey, '_cake_route_') ) === false ){ + $match = false; - for ($i = 0, $len = count(self::$routes); $i < $len; $i++) { - $originalUrl = $url; + for ($i = 0, $len = count(self::$routes); $i < $len; $i++) { + $originalUrl = $url; - if (isset(self::$routes[$i]->options['persist'], $params)) { - $url = self::$routes[$i]->persistParams($url, $params); - } + if (isset(self::$routes[$i]->options['persist'], $params)) { + $url = self::$routes[$i]->persistParams($url, $params); + } - if ($match = self::$routes[$i]->match($url)) { - $output = trim($match, '/'); - break; + if ($match = self::$routes[$i]->match($url)) { + $output = trim($match, '/'); + break; + } + $url = $originalUrl; + } + if ($match === false) { + $output = self::_handleNoRoute($url); + } + if(!empty($cacheConf)) { + Cache::write($cacheKey , $output, '_cake_route_'); } - $url = $originalUrl; - } - if ($match === false) { - $output = self::_handleNoRoute($url);