Skip to content

Instantly share code, notes, and snippets.

@kemo
Created November 28, 2011 22:43
Show Gist options
  • Select an option

  • Save kemo/1402435 to your computer and use it in GitHub Desktop.

Select an option

Save kemo/1402435 to your computer and use it in GitHub Desktop.
Kohana 3 Route cache append
<?php defined('SYSPATH') or die('No direct script access.');
class Route extends Kohana_Route {
/**
* Changed:
* - use Cache module instead of Kohana::cache()
* - append cached routes instead of assigning them directly
*/
public static function cache($save = FALSE)
{
if ($save === TRUE)
{
// Cache all defined routes
Cache::instance()->set('Route::cache()', Route::$_routes);
}
else
{
if ($routes = Cache::instance()->get('Route::cache()'))
{
Route::$_routes += $routes;
// Routes were cached
return Route::$cache = TRUE;
}
else
{
// Routes were not cached
return Route::$cache = FALSE;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment