/** * Save site configuration using keys like /public/host, /private/api_keys/google/token, etc * * @param string $key * @param $value * @param bool $create - create this key if it does not exists when true, fails if false and key isn't already present * * @return bool */ public function set(string $key, $value, bool $create = false) { list($type, $path) = explode('/', ltrim($key, '/'), 2); if ($create || $this->get($key) !== false) { $data = $this->get($type, []); $this->update($data, $path, $value); if ($model = $this->getConfigModel()) { $model::unguard(); if ($model::updateOrCreate(['type' => $type], ['data_json' => json_encode($data)])) { $this->cache->remove("config-{$type}"); return true; } } } return false; }
public function clearCache($userId) { foreach ([true, false] as $extended) { $this->cache->remove("user-groups-{$userId}-{$extended}"); } }