mirror of
https://github.com/slawkens/myaac.git
synced 2025-10-13 17:24:54 +02:00
Refactor code to use Cache::remember
This commit is contained in:
@@ -25,23 +25,16 @@ class Settings implements \ArrayAccess
|
||||
|
||||
public function load(): void
|
||||
{
|
||||
$cache = Cache::getInstance();
|
||||
if ($cache->enabled()) {
|
||||
$tmp = '';
|
||||
if ($cache->fetch('settings', $tmp)) {
|
||||
$this->settingsDatabase = unserialize($tmp);
|
||||
return;
|
||||
}
|
||||
}
|
||||
$this->settingsDatabase = Cache::remember('settings', 10 * 60, function () {
|
||||
$settingsDatabase = [];
|
||||
|
||||
$settings = ModelsSettings::all();
|
||||
foreach ($settings as $setting) {
|
||||
$this->settingsDatabase[$setting->name][$setting->key] = $setting->value;
|
||||
$settingsDatabase[$setting->name][$setting->key] = $setting->value;
|
||||
}
|
||||
|
||||
if ($cache->enabled()) {
|
||||
$cache->set('settings', serialize($this->settingsDatabase), 600);
|
||||
}
|
||||
return $settingsDatabase;
|
||||
});
|
||||
}
|
||||
|
||||
public function save($pluginName, $values): bool
|
||||
|
Reference in New Issue
Block a user