<commit_before><?php
/**
 * This is NOT a plugin
 * It is here just for modularization
 * 
 * It should be loaded for default an API modules
 * 
 */

Zend_Controller_Action_HelperBroker::addPath(APPLICATION_PATH .'/controllers/helpers');

$this->bootstrap('FrontController');
$frontController = $this->getResource('FrontController');

$dispatcher = $frontController->getDispatcher();
$request = $frontController->getRequest();

$router = $frontController->getRouter();
$router->removeDefaultRoutes();

require LIBRARY_PATH . '/ML/RouteModule.php';

$compat = new ML_Controller_Router_Route_Module(array(), $dispatcher, $request);
$router->addRoute(HOST_MODULE, $compat);

$routerConfig = new Zend_Config_Ini(APPLICATION_PATH . '/configs/'.HOST_MODULE.'Routes.ini');<commit_msg>Caching the routes to gain some performance.<commit_after><?php
/**
 * This is NOT a plugin
 * It is here just for modularization
 * 
 * It should be loaded for default an API modules
 * 
 */

Zend_Controller_Action_HelperBroker::addPath(APPLICATION_PATH .'/controllers/helpers');

$this->bootstrap('FrontController');
$frontController = $this->getResource('FrontController');

$dispatcher = $frontController->getDispatcher();
$request = $frontController->getRequest();

$router = $frontController->getRouter();
$router->removeDefaultRoutes();

require LIBRARY_PATH . '/ML/RouteModule.php';

$compat = new ML_Controller_Router_Route_Module(array(), $dispatcher, $request);
$router->addRoute(HOST_MODULE, $compat);


function getCachedIni($file)//don't use this for the Zend_Application
{
	$registry = Zend_Registry::getInstance();
	
	$sysCache = $registry->get("sysCache");
	
	$configMTime = filemtime($file);
	
	$cacheId = "cachedIni_" . md5($file);
	
	$cacheLastMTime = $sysCache->test($cacheId);
	
	if ($cacheLastMTime !== false && $configMTime <= $cacheLastMTime) {
		return $sysCache->load($cacheId, true);
	}
	
	$routerConfig = new Zend_Config_Ini($file);
    $sysCache->save($routerConfig, $cacheId, array(), null);
	
    return $routerConfig;
	
}

$routerConfig = getCachedIni(APPLICATION_PATH . '/configs/'.HOST_MODULE.'Routes.ini');
{'fraction_non_alphanumeric': 0.1514865502595564, 'fraction_numerical': 0.00047192071731949034, 'mean_word_length': 6.186440677966102, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1999829', 'n_tokens_mistral': 683, 'n_tokens_neox': 647, 'n_words': 133}