Replace caching of Theme config with generic YAML caching (#4526)
Credit to @Samuell1. Fixes issues related to complexity of the existing approach / cache invalidation by just using the caching built in to YAML::parseFile().
This commit is contained in:
parent
744263eb4b
commit
33d149fe1a
|
|
@ -50,7 +50,6 @@ class Theme
|
||||||
|
|
||||||
const ACTIVE_KEY = 'cms::theme.active';
|
const ACTIVE_KEY = 'cms::theme.active';
|
||||||
const EDIT_KEY = 'cms::theme.edit';
|
const EDIT_KEY = 'cms::theme.edit';
|
||||||
const CONFIG_KEY = 'cms::theme.config';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the theme.
|
* Loads the theme.
|
||||||
|
|
@ -341,21 +340,7 @@ class Theme
|
||||||
return $this->configCache = [];
|
return $this->configCache = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
$config = Yaml::parseFile($path);
|
||||||
if (Config::get('app.debug', false)) {
|
|
||||||
$config = Yaml::parseFile($path);
|
|
||||||
} else {
|
|
||||||
$cacheKey = self::CONFIG_KEY.'::'.$this->getDirName();
|
|
||||||
$config = Cache::rememberForever($cacheKey, function () use ($path) {
|
|
||||||
return Yaml::parseFile($path);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception $ex) {
|
|
||||||
// Cache failed
|
|
||||||
$config = Yaml::parseFile($path);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @event cms.theme.extendConfig
|
* @event cms.theme.extendConfig
|
||||||
|
|
@ -505,7 +490,6 @@ class Theme
|
||||||
|
|
||||||
Cache::forget(self::ACTIVE_KEY);
|
Cache::forget(self::ACTIVE_KEY);
|
||||||
Cache::forget(self::EDIT_KEY);
|
Cache::forget(self::EDIT_KEY);
|
||||||
Cache::forget(self::CONFIG_KEY.'::'.(new self)->getDirName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ trait ConfigMaker
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
$config = Yaml::parse(File::get($configFile));
|
$config = Yaml::parseFile($configFile);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Extensibility
|
* Extensibility
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue