Generate cache file name
Sets a "-mob" ending to cache files for visitors coming from mobile devices (phones but not tablets)

@return string file name
326692
public function strategy()
    {
        $ends = $this->currentMobile() ? '-mob' : '';

        //when session support is enabled add that to file name
        $session_str = SessionHandler::process();

        $uri = empty($_SERVER['REQUEST_URI']) ? 'uri' : $_SERVER['REQUEST_URI'];
        $query = empty($_SERVER['QUERY_STRING']) ? 'query' : $_SERVER['QUERY_STRING'];
        
        return md5($uri . $_SERVER['SCRIPT_NAME'] . $query . $session_str) . $ends;
    }
714466
private function getFileName($key)
    {
        $md5Key = md5($this->conf['prefix'] . $key);

        $dir = $this->conf['CACHE_PATH'] . substr($key, 0, strrpos($key, '/')) . DIRECTORY_SEPARATOR;
        $dir .= substr($md5Key, 0, 2) . DIRECTORY_SEPARATOR . substr($md5Key, 2, 2);
        is_dir($dir) || mkdir($dir, 0700, true);
        return $dir . DIRECTORY_SEPARATOR . $md5Key . '.php';
    }
324155
protected function generateCacheHeader()
    {
        $cacheControl = [];
        foreach ($this->getDirectives() as $directive => $value) {
            if ($value === true) {
                $cacheControl[] = $directive;
            } else {
                $cacheControl[] = $directive . '=' . $value;
            }
        }
        return implode(', ', $cacheControl);
    }
1352139
public function getCachePath(): string
    {
        $path = $this->getRuntimePath() . DIRECTORY_SEPARATOR . 'cache';
        FileHelper::createDirectory($path);
        return $path;
    }
582832
public function getName() {

		$name = '';

		foreach ( $this->caches as $cache ) {
			$name = $name . '::' . $cache->getName();
		}

		return __CLASS__ . $name;
	}
109014
protected function generateCacheKey(): string
    {
        return sprintf(
            '%s:%s:%s',
            $this->command,
            $this->collection->getNamespace(),
            md5(serialize($this->params))
        );
    }
912477
public function get_cache()
    {
        $args = func_get_args();
        $cache_path = call_user_func_array(array($this, 'get_path'), $args);

        if (is_file($cache_path)) {
            return file_get_contents($cache_path);
        }
        return null;
    }
28853
private function filename()
    {
        $to = str_replace(['@', '.'], ['_at_', '_'], array_keys($this->message->getTo())[0]);

        return str_slug($this->message->getDate().'_'.$to.'_'.$this->message->getSubject(), '_').'.html';
    }
75389
private function createCache()
    {
        $cachePath = $this->getCachePath();
        $content   = json_encode([], JSON_PRETTY_PRINT);

        $this->files->put($cachePath, $content);

        return collect(json_decode($content, true));
    }
896334
private function generateHash()
    {
        $ctx = hash_init('md5');

        // We don't need to read the file contents if the source has a path
        if ($this->source->path()) {
            hash_update_file($ctx, $this->source->path());
        } else {
            hash_update($ctx, $this->source->contents());
        }

        return hash_final($ctx);
    }
189589
protected function getTemplateName()
    {
        $templateName = '';
        $templateFile = '';

        if (isset($this->ffData['templateFile'])) {
            $templateFile = $this->ffData['templateFile'];
        } elseif (isset($this->conf['defaultTemplateFileName'])) {
            $templateFile = $this->conf['defaultTemplateFileName'];
        }

        if ($templateFile === $this->conf['defaultTemplateFileName'] ||
            $templateFile === 'default') {
            $templateName = 'default';
        }

        // cutting off the file extension
        if ($templateName !== 'default') {
            $templateName = substr($templateFile, 0, strrpos($templateFile, '.'));
        }

        return $templateName;
    }
1088216
public function getFilename()
    {
        if (!$this->fileName) {
            $matcher = $this->getFileMatcher();
            $this->fileName = $this->searchFile($matcher);
        }

        return $this->fileName;
    }
266226
protected function _buildCache()
    {
        $cacheTpl = "<?php\n\$source_version=%s;\n\$cache_version=%s;\n\$properties=%s;\n\$browsers=%s;\n\$userAgents=%s;\n\$patterns=%s;\n";

        $propertiesArray = $this->_array2string($this->_properties);
        $patternsArray = $this->_array2string($this->_patterns);
        $userAgentsArray = $this->_array2string($this->_userAgents);
        $browsersArray = $this->_array2string($this->_browsers);

        return sprintf(
            $cacheTpl,
            "'" . $this->_source_version . "'",
            "'" . self::CACHE_FILE_VERSION . "'",
            $propertiesArray,
            $browsersArray,
            $userAgentsArray,
            $patternsArray
        );
    }
194625
public function getCacheDir() {
    if (true === $this->_checkCacheDir()) {
      $filename = $this->getCache();
      $filename = preg_replace('/[^0-9a-z\.\_\-]/i', '', strtolower($filename));
      return $this->getCachePath() . $this->_getHash($filename) . $this->getExtension();
    }
  }
357834
private function generateFileName() {
		return $this -> directory -> entity() -> getPath() . date($this -> getMode()) . $this -> getSuffix() . $this -> getExtension();
	}
564855
private function getFileName($key) {
		$key = str_replace(' ', '', $key);
		$cacheDir = rtrim($this->cachePath, '\\/') . '/';
		if ($this->directoryLevel > 0) {
			$hash = abs(crc32($key));
			$cacheDir .= $hash % 1024;
			for($i = 1; $i < $this->directoryLevel; ++$i) {
				if (($prefix = substr($hash, $i, 2)) !== false) {
					$cacheDir .= '/' . $prefix;
				}
			}
		}
		return $cacheDir . '/' . md5($key) . $this->cacheExt;
	}
279699
public function getUrlPageName()
    {
        if (static::$urlPageName !== null) {
            return static::$urlPageName;
        }

        /*
         * Cache
         */
        $key = 'urlMaker'.$this->urlComponentName.crc32(get_class($this));

        $cached = Cache::get($key, false);
        if ($cached !== false && ($cached = @unserialize($cached)) !== false) {
            $filePath = array_get($cached, 'path');
            $mtime = array_get($cached, 'mtime');
            if (!File::isFile($filePath) || ($mtime != File::lastModified($filePath))) {
                $cached = false;
            }
        }

        if ($cached !== false) {
            return static::$urlPageName = array_get($cached, 'fileName');
        }

        /*
         * Fallback
         */
        $page = null;
        $useProperty = property_exists($this, 'urlComponentProperty');

        if ($useProperty) {
            $page = Page::whereComponent($this->urlComponentName, $this->urlComponentProperty, '1')->first();
        }

        if (!$useProperty || !$page) {
            $page = Page::withComponent($this->urlComponentName)->first();
        }

        if (!$page) {
            throw new ApplicationException(sprintf(
                'Unable to a find a primary component "%s" for generating a URL in %s.',
                $this->urlComponentName,
                get_class($this)
            ));
        }

        $baseFileName = $page->getBaseFileName();
        $filePath = $page->getFilePath();

        $cached = [
            'path'     => $filePath,
            'fileName' => $baseFileName,
            'mtime'    => @File::lastModified($filePath)
        ];

        Cache::put($key, serialize($cached), Config::get('cms.parsedPageCacheTTL', 1440));

        return static::$urlPageName = $baseFileName;
    }