mirror of
https://github.com/SuiteCRM/SuiteCRM-Core.git
synced 2025-09-13 00:42:08 +08:00
Fix #493 - Improve Cache Clear Speed
This commit is contained in:
parent
e3e9956e12
commit
08f3f07432
3 changed files with 66 additions and 5 deletions
|
@ -29,7 +29,13 @@ $classicview_routing_exclusions = [
|
|||
'any' => [
|
||||
'ShowDuplicates'
|
||||
],
|
||||
'administration' => [
|
||||
'upgrade',
|
||||
'repair'
|
||||
],
|
||||
'Administration' => [
|
||||
'upgrade',
|
||||
'repair',
|
||||
'UpgradeWizard_prepare',
|
||||
'UpgradeWizard_commit'
|
||||
],
|
||||
|
|
|
@ -128,11 +128,49 @@ class RepairAndClear
|
|||
|
||||
/////////////OLD
|
||||
|
||||
public function clearCoreCache()
|
||||
/**
|
||||
* Clear Symfony Cache
|
||||
* @return void
|
||||
*/
|
||||
public function clearCoreCache() : void
|
||||
{
|
||||
if (empty($GLOBALS['installing'])) {
|
||||
$coreCachePath = __DIR__ . '/../../../../cache/';
|
||||
rmdir_recursive($coreCachePath);
|
||||
$fs = new Symfony\Component\Filesystem\Filesystem();
|
||||
$tempId = uniqid();
|
||||
|
||||
$this->clearCacheDir($fs, $tempId, '/prod');
|
||||
$this->clearCacheDir($fs, $tempId, '/dev');
|
||||
$this->clearCacheDir($fs, $tempId, '/test');
|
||||
$this->clearCacheDir($fs, $tempId, '/qa');
|
||||
|
||||
require_once "include/portability/Services/Cache/CacheManager.php";
|
||||
(new CacheManager())->markAsNeedsUpdate('rebuild_all');
|
||||
|
||||
if (function_exists('opcache_reset')) {
|
||||
opcache_reset();
|
||||
}
|
||||
|
||||
if (function_exists('apcu_clear_cache')) {
|
||||
apcu_clear_cache();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename and remove cache subdirectory
|
||||
* @param $fs
|
||||
* @param $tempId
|
||||
* @param $cacheFolder
|
||||
* @return void
|
||||
*/
|
||||
protected function clearCacheDir($fs, $tempId, $cacheFolder) : void
|
||||
{
|
||||
$cacheDirPath = __DIR__ . '/../../../../cache' . $cacheFolder;
|
||||
|
||||
if($fs->exists($cacheDirPath)){
|
||||
$fs->rename($cacheDirPath, $cacheDirPath . '_' . $tempId . '_deprecated/');
|
||||
$fs->mkdir($cacheDirPath);
|
||||
$fs->remove($cacheDirPath . '_' . $tempId . '_deprecated/');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue