src/Leevel/Option/Console/Cache.php
protected function writeCache(string $cachePath, array $data): void
    {
        $relativePathLevel = $this->computeRelativePath($cachePath);
        $isRelativePath = $relativePathLevel > -1;

        $content = '<?'.'php /* '.date('Y-m-d H:i:s').
            ' */ ?'.'>';

        if ($isRelativePath) {
            $content .= PHP_EOL.'<?'.'php $baseDir = dirname(__DIR__, '.$relativePathLevel.'); ?>';
        }

        $content .= PHP_EOL.'<?'.'php return '.
            var_export($data, true).'; ?'.'>';

        if ($isRelativePath) {
            $content = $this->replaceRelativePath($content);
        }

        create_file($cachePath, $content);
    }
protected function writeCache(string $cachePath, array $data): void
    {
        $relativePathLevel = $this->computeRelativePath($cachePath);
        $isRelativePath = $relativePathLevel > -1;

        $content = '<?'.'php /* '.date('Y-m-d H:i:s').
            ' */ ?'.'>';

        if ($isRelativePath) {
            $content .= PHP_EOL.'<?'.'php $baseDir = dirname(__DIR__, '.$relativePathLevel.'); ?>';
        }

        $content .= PHP_EOL.'<?'.'php return '.
            var_export($data, true).'; ?'.'>';

        if ($isRelativePath) {
            $content = $this->replaceRelativePath($content);
        }

        create_file($cachePath, $content);
    }
写入缓存.

@param string $cachePath
@param array  $data