/** * Initialization that sets a base key and the driver based on configuration settings * * @param Grav $grav * * @return void */ public function init(Grav $grav) { /** @var Config $config */ $this->config = $grav['config']; $this->now = time(); $this->cache_dir = $grav['locator']->findResource('cache://doctrine', true, true); /** @var Uri $uri */ $uri = $grav['uri']; $prefix = $this->config->get('system.cache.prefix'); if (is_null($this->enabled)) { $this->enabled = (bool) $this->config->get('system.cache.enabled'); } // Cache key allows us to invalidate all cache on configuration changes. $this->key = ($prefix ? $prefix : 'g') . '-' . substr(md5($uri->rootUrl(true) . $this->config->key() . GRAV_VERSION), 2, 8); $this->driver_setting = $this->config->get('system.cache.driver'); $this->driver = $this->getCacheDriver(); // Set the cache namespace to our unique key $this->driver->setNamespace($this->key); }