/** * @return array */ public function DoAppDelayStart() { $this->Plugins()->RunHook('service.app-delay-start-begin'); \RainLoop\Utils::UpdateConnectionToken(); $bMainCache = false; $bFilesCache = false; $bVersionsCache = false; $iOneDay1 = 60 * 60 * 23; $iOneDay2 = 60 * 60 * 25; $iOneDay3 = 60 * 60 * 30; $sTimers = $this->StorageProvider()->Get(null, \RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY, 'Cache/Timers', ''); $aTimers = \explode(',', $sTimers); $iMainCacheTime = !empty($aTimers[0]) && \is_numeric($aTimers[0]) ? (int) $aTimers[0] : 0; $iFilesCacheTime = !empty($aTimers[1]) && \is_numeric($aTimers[1]) ? (int) $aTimers[1] : 0; $iVersionsCacheTime = !empty($aTimers[2]) && \is_numeric($aTimers[2]) ? (int) $aTimers[2] : 0; if (0 === $iMainCacheTime || $iMainCacheTime + $iOneDay1 < \time()) { $bMainCache = true; $iMainCacheTime = \time(); } if (0 === $iFilesCacheTime || $iFilesCacheTime + $iOneDay2 < \time()) { $bFilesCache = true; $iFilesCacheTime = \time(); } if (0 === $iVersionsCacheTime || $iVersionsCacheTime + $iOneDay3 < \time()) { $bVersionsCache = true; $iVersionsCacheTime = \time(); } if ($bMainCache || $bFilesCache || $bVersionsCache) { if (!$this->StorageProvider()->Put(null, \RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY, 'Cache/Timers', \implode(',', array($iMainCacheTime, $iFilesCacheTime, $iVersionsCacheTime)))) { $bMainCache = $bFilesCache = $bVersionsCache = false; } } if ($bMainCache) { $this->Logger()->Write('Cacher GC: Begin'); $this->Cacher()->GC(48); $this->Logger()->Write('Cacher GC: End'); } else { if ($bFilesCache) { $this->Logger()->Write('Files GC: Begin'); $this->FilesProvider()->GC(48); $this->Logger()->Write('Files GC: End'); } else { if ($bVersionsCache) { $oPremProvider = $this->PremProvider(); if ($oPremProvider) { $oPremProvider->ClearOldVersion(); } } } } $this->Plugins()->RunHook('service.app-delay-start-end'); return $this->TrueResponse(__FUNCTION__); }