Init all settings
@param bool $no_cache fetch data from cache or not
@return array
345695
public function init($no_cache = false)
    {
        $this->bootCacher();

        // From local cache
        if (self::$_cached_settings && is_array(self::$_cached_settings) && !$no_cache) {
            return self::$_cached_settings;
        }

        if ($no_cache) {
            // Force cache invalidation
            self::$_cached_settings = [];
        } else {
            // Get from cache
            self::$_cached_settings = Cacher::getInstance()->getDefaultCacher()->get(self::CACHE_KEY);
        }

        if (!self::$_cached_settings && SQL::getInstance()->tableExists('cms_settings')) {
            // Get from DB
            $settings_collection = new SettingEntityRepository();
            self::$_cached_settings = $settings_collection->getPairs('value', 'name');
            Cacher::getInstance()->getDefaultCacher()->set(self::CACHE_KEY, self::$_cached_settings);
        }

        if (!is_array(self::$_cached_settings)) {
            self::$_cached_settings = [];
        }

        return self::$_cached_settings;
    }
393061
public function cache()
    {
        $keys = [
            'enable_caching',
            'cache_duration'
        ];
        $this->CacheSettings = $this->loadModel('Wasabi/Core.CacheSettings');
        $settings = $this->CacheSettings->getKeyValues(new CacheSetting(), $keys);
        if ($this->request->is('post') && !empty($this->request->data)) {
            $settings = $this->CacheSettings->newEntity($this->request->data);
            if (!$settings->errors()) {
                if ($this->CacheSettings->saveKeyValues($settings, $keys)) {
                    $this->Flash->success(__d('wasabi_core', 'The cache settings have been updated.'));
                    $this->redirect(['action' => 'cache']);
                    return;
                } else {
                    $this->Flash->error($this->dbErrorMessage);
                }
            } else {
                $this->Flash->error($this->formErrorMessage);
            }
        }
        $this->set([
            'settings' => $settings,
            'cacheDurations' => $this->CacheSettings->cacheDurations
        ]);
    }
393919
protected static function initialise_cachestore_instances(array $stores, cache_definition $definition) {
        $return = array();
        $factory = cache_factory::instance();
        foreach ($stores as $name => $details) {
            $store = $factory->create_store_from_config($name, $details, $definition);
            if ($store !== false) {
                $return[] = $store;
            }
        }
        return $return;
    }
735936
public function read_cache($cache_id)
	{
		// make sure we have all config data
		empty($this->cache_dir) and $this->cache_dir = \Config::get('cache_dir', APPPATH.'cache/');
		empty($this->cache_lifetime) and $this->cache_lifetime = \Config::get('cache_lifetime', 3600);

		if ($cached = $this->cache($cache_id))
		{
			$this->cached_paths = $cached;
		}
	}
1055539
public function forRole(string $role_id, bool $no_cache = false): array
    {
        if (($collection = &$this->cacheKey(__FUNCTION__, $role_id)) !== null && !$no_cache) {
            return $collection; // Already cached this.
        }
        $collection = []; // Initialize.

        if ($role_id === 'super_admin') {
            $role_id = 'administrator';

            if ($this->Wp->is_multisite) {
                $collection = array_merge($collection, [
                    'manage_network'         => 'manage_network',
                    'manage_sites'           => 'manage_sites',
                    'manage_network_users'   => 'manage_network_users',
                    'manage_network_plugins' => 'manage_network_plugins',
                    'manage_network_themes'  => 'manage_network_themes',
                    'manage_network_options' => 'manage_network_options',
                ]);
            }
        }
        $role = get_role($role_id); // If role exists.

        foreach (array_keys($role->capabilities ?? []) as $_role_cap) {
            $collection[$_role_cap] = $_role_cap;
        } // unset($_role_cap); // Housekeeping.

        asort($collection, SORT_NATURAL);

        return $collection;
    }
272329
protected function getSettingsConfig(): array
    {
        if (!$this->cache instanceof Cache) {
            $this->items = $this->model->getSettings();
        } else {
            $cacheItems = $this->cache->get($this->cacheKey);
            if (!empty($cacheItems)) {
                $this->items = $cacheItems;
            } else {
                $this->items = $this->model->getSettings();
                $this->cache->set($this->cacheKey, $this->items);
            }
        }

        return $this->items;
    }
601318
static function get($namespace, $name = null, $isall = false)
    {
        $cacheName = 'config:'.$namespace;
        if (!Cache::has($cacheName)) {
            $data = self::setCache($namespace);
        } else {
            $data = Cache::get($cacheName, []);
            if($name) {
                if(!$isall) return isset($data[$name]['value']) ? $data[$name]['value'] : null;
                return isset($data[$name]) ? $data[$name] : [];
            }
        }
        if(!$isall) {
            $rdata = array();
            foreach ($data as $key => $value) {
                $rdata[$key] = $value['value'];
            }
            return $rdata;
        }
        return $data;
    }
721669
private function init()
    {
        if (!is_dir($this->options['path'])) {
            if (mkdir($this->options['path'], 0755, true) && chmod($this->options['path'], 0755)) {
                return true;
            }
        }

        if (!is_writeable($this->options['path'])) {
            throw new CacheException('Cache Path: '.$this->options['path'].' is not writable');
        }

        return false;
    }
729939
public static function initialize() {
		if(defined('DACHI_KERNEL'))
			return false;

		define('DACHI_KERNEL', true);

		require_once('Kernel.functions.php');

		getExecutionTime();
		date_default_timezone_set(Configuration::get('dachi.timezone'));
		error_reporting(-1);
		define('WORKING_DIRECTORY', getcwd());

		Session::start(Configuration::get('sessions.name'), Configuration::get('sessions.domain', false), Configuration::get('sessions.secure', false));
	}
135431
public function getAll()
    {
        $this->initializeOnDemand();
        $result = array();

        foreach ($this->cache as $key => $options) {
            $result[$key] = $options[ConstProviderInterface::CACHE_PARAM_VALUE];
        }

        return $result;
    }
519483
private function _populate_cache()
    {
        if ($this->_use_json) {
            if (is_readable($this->_cache_file) &&
            ($loaded = @json_decode(Common::getContents($this->_cache_file, ''), true)) && is_array($loaded)) {
                $this->_existing_cache_vals = $loaded;
            }
        } else {
            if (is_readable($this->_cache_file) &&
            ($loaded = @unserialize(Common::getContents($this->_cache_file, false))) && is_array($loaded)) {
                $this->_existing_cache_vals = $loaded;
            }
        }
    }
585835
private function _loadCache() {
    if (true === file_exists($this->getCacheDir())) {
      $file = file_get_contents($this->getCacheDir());
      return json_decode($file, true);
    } else {
      return false;
    }
  }
698616
public static function _init()
	{
		// fetch and store the user agent
		static::$user_agent = \Input::server('http_user_agent', '');

		// fetch and process the configuration
		\Config::load('agent', true);

		static::$config = array_merge(static::$defaults, \Config::get('agent', array()));

		// validate the browscap configuration
		if ( ! is_array(static::$config['browscap']))
		{
			static::$config['browscap'] = static::$defaults['browscap'];
		}
		else
		{
			if ( ! array_key_exists('enabled', static::$config['browscap']) or ! is_bool(static::$config['browscap']['enabled']))
			{
				static::$config['browscap']['enabled'] = true;
			}

			if ( ! array_key_exists('url', static::$config['browscap']) or ! is_string(static::$config['browscap']['url']))
			{
				static::$config['browscap']['url'] = static::$defaults['browscap']['url'];
			}

			if ( ! array_key_exists('file', static::$config['browscap']) or ! is_string(static::$config['browscap']['file']))
			{
				static::$config['browscap']['file'] = static::$defaults['browscap']['file'];
			}

			if ( ! array_key_exists('method', static::$config['browscap']) or ! is_string(static::$config['browscap']['method']))
			{
				static::$config['browscap']['method'] = static::$defaults['browscap']['method'];
			}
			static::$config['browscap']['method'] = strtolower(static::$config['browscap']['method']);
		}

		// validate the cache configuration
		if ( ! is_array(static::$config['cache']))
		{
			static::$config['cache'] = static::$defaults['cache'];
		}
		else
		{
			if ( ! array_key_exists('driver', static::$config['cache']) or ! is_string(static::$config['cache']['driver']))
			{
				static::$config['cache']['driver'] = static::$defaults['cache']['driver'];
			}

			if ( ! array_key_exists('expiry', static::$config['cache']) or ! is_numeric(static::$config['cache']['expiry']) or static::$config['cache']['expiry'] < 7200)
			{
				static::$config['cache']['expiry'] = static::$defaults['cache']['expiry'];
			}

			if ( ! array_key_exists('identifier', static::$config['cache']) or ! is_string(static::$config['cache']['identifier']))
			{
				static::$config['cache']['identifier'] = static::$defaults['cache']['identifier'];
			}
		}

		// do we have a user agent?
		if (static::$user_agent)
		{
			// try the build in get_browser() method
			if (ini_get('browscap') == '' or false === $browser = get_browser(static::$user_agent, true))
			{
				// if it fails, emulate get_browser()
				$browser = static::get_from_browscap();
			}

			if ($browser)
			{
				// save it for future reference
				static::$properties = array_change_key_case($browser);
			}
		}
	}
48838
def _cache_init(self):
        """"""
        cache_ = cache.get(self.CACHE_ENTRY_NAME)

        if cache_ is None:
            categories = get_category_model().objects.order_by('sort_order')

            ids = {category.id: category for category in categories}
            aliases = {category.alias: category for category in categories if category.alias}

            parent_to_children = OrderedDict()  # Preserve aliases order.
            for category in categories:
                parent_category = ids.get(category.parent_id, False)
                parent_alias = None
                if parent_category:
                    parent_alias = parent_category.alias
                if parent_alias not in parent_to_children:
                    parent_to_children[parent_alias] = []
                parent_to_children[parent_alias].append(category.id)

            cache_ = {
                self.CACHE_NAME_IDS: ids,
                self.CACHE_NAME_PARENTS: parent_to_children,
                self.CACHE_NAME_ALIASES: aliases
            }

            cache.set(self.CACHE_ENTRY_NAME, cache_, self.CACHE_TIMEOUT)

        self._cache = cache_
1056621
public static function _init()
	{
		\Config::load('session', true);

		if (\Config::get('session.auto_initialize', true))
		{
			static::instance();
		}

		if (\Config::get('session.native_emulation', false))
		{
			// emulate native PHP sessions
			session_set_save_handler (
				// open
				function ($savePath, $sessionName) {
				},
				// close
				function () {
				},
				// read
				function ($sessionId) {
					// copy all existing session vars into the PHP session store
					$_SESSION = \Session::get();
					$_SESSION['__org'] = $_SESSION;
				},
				// write
				function ($sessionId, $data) {
					// get the original data
					$org = isset($_SESSION['__org']) ? $_SESSION['__org'] : array();
					unset($_SESSION['__org']);

					// do we need to remove stuff?
					if ($remove = array_diff_key($org, $_SESSION))
					{
						\Session::delete(array_keys($remove));
					}

					// add or update the remainder
					empty($_SESSION) or \Session::set($_SESSION);
				},
				// destroy
				function ($sessionId) {
					\Session::destroy();
				},
				// gc
				function ($lifetime) {
				}
			);
		}
	}
418579
public function initialise(cache_definition $definition) {
        $this->definition = $definition;
        $this->hash       = $definition->generate_definition_hash();
        return true;
    }
383318
private function getCachedStats()
    {
        if (!Cache::has(self::CACHE_NAME)) {
            $this->initCachedStats();
        }

        return new Collection(
            Cache::get(self::CACHE_NAME)
        );
    }