mirror of
https://github.com/friendica/friendica
synced 2024-12-23 12:00:16 +00:00
Add routes file recompute on last modification time change
This commit is contained in:
parent
472cc10ac5
commit
df23690a93
1 changed files with 14 additions and 1 deletions
|
@ -268,20 +268,33 @@ class Router
|
||||||
* The cached "routerDispatchData" lasts for a day, and must be cleared manually when there
|
* The cached "routerDispatchData" lasts for a day, and must be cleared manually when there
|
||||||
* is any changes in the enabled addons list.
|
* is any changes in the enabled addons list.
|
||||||
*
|
*
|
||||||
|
* Additionally, we check for the base routes file last modification time to automatically
|
||||||
|
* trigger re-computing the dispatch data.
|
||||||
|
*
|
||||||
* @return array|mixed
|
* @return array|mixed
|
||||||
* @throws HTTPException\InternalServerErrorException
|
* @throws HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
private function getCachedDispatchData()
|
private function getCachedDispatchData()
|
||||||
{
|
{
|
||||||
$routerDispatchData = $this->cache->get('routerDispatchData');
|
$routerDispatchData = $this->cache->get('routerDispatchData');
|
||||||
|
$lastRoutesFileModifiedTime = $this->cache->get('lastRoutesFileModifiedTime');
|
||||||
|
$forceRecompute = false;
|
||||||
|
|
||||||
if ($routerDispatchData) {
|
if ($this->baseRoutesFilepath && file_exists($this->baseRoutesFilepath)) {
|
||||||
|
$routesFileModifiedTime = filemtime($this->baseRoutesFilepath);
|
||||||
|
$forceRecompute = $lastRoutesFileModifiedTime != $routesFileModifiedTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$forceRecompute && $routerDispatchData) {
|
||||||
return $routerDispatchData;
|
return $routerDispatchData;
|
||||||
}
|
}
|
||||||
|
|
||||||
$routerDispatchData = $this->getDispatchData();
|
$routerDispatchData = $this->getDispatchData();
|
||||||
|
|
||||||
$this->cache->set('routerDispatchData', $routerDispatchData, Duration::DAY);
|
$this->cache->set('routerDispatchData', $routerDispatchData, Duration::DAY);
|
||||||
|
if (!empty($routesFileModifiedTime)) {
|
||||||
|
$this->cache->set('lastRoutesFileMtime', $routesFileModifiedTime, Duration::MONTH);
|
||||||
|
}
|
||||||
|
|
||||||
return $routerDispatchData;
|
return $routerDispatchData;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue