Call Route::_ method one million times for different url
low memory usage
high memory usage
memory_limit = 1G
One of them can be a solution;
Labels |
Added:
No Code Attached Yet
|
Yes, it is fine for general real-life usage.
But in my case, there are more than three million pages on my website.
I have a CLI app in Joomla to build a sitemap.
Router::$cache
is a protected variable, so I can't access it directly.
I have to remove or disable that cache in my app.
How can I override class Router
or class SiteRouter
?
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2023-03-13 11:24:36 |
Closed_By | ⇒ | Hackwar |
You can create a system plugin which loads your version of the router class either during construction of the plugin object or on the event onAfterInitialise. We will not remove the cache for the router in the CMS by default.
<?php
use Joomla\CMS\Plugin\CMSPlugin;
class plgSystemMyownrouter extends CMSPlugin
{
public function onAfterInitialise()
{
require_once __DIR__ . '/router.php';
}
}
And in the router.php you have your copy of the router class.
Thanks !
Our routing system stores the processed URLs into
Router::$cache
so that it does not have to handle building process more than one time for the same URL. Please note that this isin memory
cache, data inRouter::$cache
are the URLs for each page load. In real life usages, there won't be that large number of URLs per page, so I think the current implementation is fine.Since this is in memory cache for each page load, I think the solutions you suggested are not applicable, too.