Sets up this backend by creating the required cache directory if it doesn't exist yet

@return Result
@api
490267
public function setup(): Result
    {
        $result = new Result();
        try {
            $this->configureCacheDirectory();
        } catch (Exception $exception) {
            $result->addError(new Error('Failed to configure cache directory: %s', $exception->getCode(), [$exception->getMessage()], 'Cache Directory'));
        }
        return $result;
    }
612275
private function initCache()
    {
        // Create a new Container object, needed by the cache manager.
        $container = new Container;

        // The CacheManager creates the cache "repository" based on config values
        $container['config'] = [
            'cache.default' => 'file',
            'cache.stores.file' => [
                'driver' => 'file',
                'path' => __DIR__ . '/cache'
            ]
        ];

        // To use the file cache driver we need an instance of Illuminate's Filesystem, also stored in the container
        $container['files'] = new Filesystem;
        // Create the CacheManager
        $cacheManager = new CacheManager($container);

        // Get the default cache driver (file in this case)
        return $cacheManager->store();

    }
877637
public function createFolder()
    {
        if ($this->storage->exists($this)) {
            return false;
        }

        $this->storage->makeDirectory(0777, true, true);
    }
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
        ]);
    }
843880
protected function generatePath()
    {
        $filesystem = new Filesystem();
        $path = $this->cacheFolder;
        $path = trim($path, '/');

        if (!empty($this->namespace)) {
            $path .= '/'.$this->namespace;
        }

        if (!$filesystem->exists($this->projectDir.'/'.$path)) {
            $filesystem->mkdir($this->projectDir.'/'.$path);
        }
        $this->cacheFolderWithNamespace = $path;
    }
1260600
protected function makeCacheableDir()
    {
        if ($this->configure['cache']) {
            $this->makeDirectories(strval($this->configure['cache_dir']), 0775);
            $this->cacheable = true;
        }
    }
729730
protected static function BuildCache() {
      self::CalculateData(self::$Categories);
      self::JoinRecentPosts(self::$Categories);
      Gdn::Cache()->Store(self::CACHE_KEY, self::$Categories, array(Gdn_Cache::FEATURE_EXPIRY => 600));
   }
523384
private static function setup()
    {
        $files = ['Routes', 'Setup', 'Response'];
        $folder = static::$root.'Setup'.'/';

        self::call($files, $folder);

        $files = ['Database', 'Panel', 'Security', 'Maintenance', 'Loggin', 'Translator', 'App', 'Robots'];
        $folder = static::$root.'Setup/Documentations'.'/';

        self::call($files, $folder);

        $files = ['AppSetupException'];
        $folder = static::$root.'Setup/Exceptions'.'/';

        self::call($files, $folder);
    }
1349332
protected function _set()
	{
		$payload = $this->prep_contents();
		$id_path = $this->identifier_to_path($this->identifier);

		// create directory if necessary
		$subdirs = explode(DS, $id_path);
		if (count($subdirs) > 1)
		{
			array_pop($subdirs);

			// check if specified subdir exists
			if ( ! @is_dir(static::$path.implode(DS, $subdirs)))
			{
				// recursively create the directory. we can't use mkdir permissions or recursive
				// due to the fact that mkdir is restricted by the current users umask
				$basepath = rtrim(static::$path,DS);
				$chmod = \Config::get('file.chmod.folders', 0775);
				foreach ($subdirs as $dir)
				{
					$basepath .= DS.$dir;
					if ( ! is_dir($basepath))
					{
						try
						{
							if ( ! mkdir($basepath))
							{
								return false;
							}
							chmod($basepath, $chmod);
						}
						catch (\PHPErrorException $e)
						{
							return false;
						}
					}
				}
			}
		}

		// write the cache
		$file = static::$path.$id_path.'.cache';

		$handle = fopen($file, 'c');

		if ( ! $handle)
		{
			return false;
		}

		// wait for a lock
		while ( ! flock($handle, LOCK_EX));

		// truncate the file
		ftruncate($handle, 0);

		// write the session data
		fwrite($handle, $payload);

		//release the lock
		flock($handle, LOCK_UN);

		// close the file
		fclose($handle);

		// set the correct rights on the file
		chmod($file, \Config::get('file.chmod.files', 0666));

		return true;
	}
33937
protected function initAdminDirectory()
    {
        $this->directory = config('admin.directory');

        if (is_dir($this->directory)) {
            $this->line("<error>{$this->directory} directory already exists !</error> ");

            return;
        }

        $this->makeDir('/');
        $this->line('<info>Admin directory was created:</info> '.str_replace(base_path(), '', $this->directory));

        $this->makeDir('Controllers');

        $this->createHomeController();
        $this->createExampleController();
        //$this->createAuthController();
        //$this->createAdministratorController();

        //$this->createMenuFile();
        $this->createBootstrapFile();
        $this->createRoutesFile();

        //$this->copyLanguageFiles();
    }
1053931
public function setCache()
    {
        if (!$this->cache) {
            $this->cache = new CacheStorageHelper(
                CacheStorageHelper::ADAPTOR_DATABASE,
                'Health',
                $this->em->getConnection()
            );
        }
        usort(
            $this->delays,
            function ($a, $b) {
                return $b['avg_delay_s'] - $a['avg_delay_s'];
            }
        );
        $this->cache->set('delays', $this->delays, null);
        $this->cache->set('lastCached', time(), null);
        $this->delays = [];
    }
525901
protected function setCache()
    {
        if ($this->cache) {
            $cacheFile = $this->getCacheFile();
            file_put_contents($cacheFile, $this->templateOutput);
        }
    }
758841
public function getCacheSystem()
    {
        if (is_null($this->cache)) {
            $this->cache = new \Gregwar\Cache\Cache();
            $this->cache->setCacheDirectory($this->cacheDir);
        }

        return $this->cache;
    }
89333
private function prepareSouceDirectory()
	{
		if (!file_exists($this->sourceFolder))
		{
			$this->say('Creating source folder');
			$this->_mkdir($this->sourceFolder);
		}
	}
1324692
public function createClusteredConfiguration()
    {
        $retval = false;

        if ($this->apache_config_path) {
            $index_list = $this->nb_server->getSitesIndex();
            $index_list->iterate(
                function ($site_key, $nb_site) {
                    $this->createSiteFolders($nb_site);
                    $this->createClusteredFile($nb_site);

                    return true;
                }
            );
            $this->createClusteredIndex($index_list);
            $retval = true;
        }

        return $retval;
    }
150251
public function getCacheDir()
	{
		if ($this->cacheDir === null) {
			$this->setCacheDir(dirname(__FILE__).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR);
		}

		return $this->cacheDir;
	}
2051
public function setup(): Result
    {
        $result = new Result();
        try {
            $this->connect();
            $connection = DriverManager::getConnection(['pdo' => $this->databaseHandle]);
        } catch (Exception | FilesException |DBALException $exception) {
            $result->addError(new Error($exception->getMessage(), $exception->getCode(), [], 'Connection failed'));
            return $result;
        }

        try {
            $tablesExist = $connection->getSchemaManager()->tablesExist([$this->cacheTableName, $this->tagsTableName]);
        } /** @noinspection PhpRedundantCatchClauseInspection */ catch (DBALException $exception) {
            $result->addError(new Error($exception->getMessage(), $exception->getCode(), [], 'Connection failed'));
            return $result;
        }
        if ($tablesExist) {
            $result->addNotice(new Notice('Tables "%s" and "%s" (already exists)', null, [$this->cacheTableName, $this->tagsTableName]));
        } else {
            $result->addNotice(new Notice('Creating database tables "%s" & "%s"...', null, [$this->cacheTableName, $this->tagsTableName]));
        }

        $fromSchema = $connection->getSchemaManager()->createSchema();
        $schemaDiff = (new Comparator())->compare($fromSchema, $this->getCacheTablesSchema());

        try {
            $statements = $schemaDiff->toSaveSql($connection->getDatabasePlatform());
        } catch (DBALException $exception) {
            $result->addError(new Error($exception->getMessage(), $exception->getCode(), [], 'Connection failed'));
            return $result;
        }
        if ($statements === []) {
            $result->addNotice(new Notice('Table schema is up to date, no migration required'));
            return $result;
        }
        $connection->beginTransaction();
        try {
            foreach ($statements as $statement) {
                $result->addNotice(new Notice('<info>++</info> %s', null, [$statement]));
                $connection->exec($statement);
            }
            $connection->commit();
        } catch (\Exception $exception) {
            try {
                $connection->rollBack();
            } catch (\Exception $exception) {
            }
            $result->addError(new Error('Exception while trying to setup PdoBackend: %s', $exception->getCode(), [$exception->getMessage()]));
        }
        return $result;
    }