X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/b1b8067cbe79d7ca2bca9021ab9d37465b0c44fe..refs/pull/5280/head:/app/Api/ApiDocsGenerator.php diff --git a/app/Api/ApiDocsGenerator.php b/app/Api/ApiDocsGenerator.php index 3cd33ffa5..9cae80617 100644 --- a/app/Api/ApiDocsGenerator.php +++ b/app/Api/ApiDocsGenerator.php @@ -27,13 +27,16 @@ class ApiDocsGenerator { $appVersion = trim(file_get_contents(base_path('version'))); $cacheKey = 'api-docs::' . $appVersion; - if (Cache::has($cacheKey) && config('app.env') === 'production') { - $docs = Cache::get($cacheKey); - } else { - $docs = (new ApiDocsGenerator())->generate(); - Cache::put($cacheKey, $docs, 60 * 24); + $isProduction = config('app.env') === 'production'; + $cacheVal = $isProduction ? Cache::get($cacheKey) : null; + + if (!is_null($cacheVal)) { + return $cacheVal; } + $docs = (new ApiDocsGenerator())->generate(); + Cache::put($cacheKey, $docs, 60 * 24); + return $docs; }