Skip to content

Commit 0628c28

Browse files
committed
Cache: Increases database cache value size
Upped from text to medium text. Aligns with modern Laravel default. Fixes #4453 where were reaching the limit of TEXT.
1 parent 3914784 commit 0628c28

File tree

2 files changed

+41
-5
lines changed

2 files changed

+41
-5
lines changed

app/Api/ApiDocsGenerator.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Illuminate\Contracts\Container\BindingResolutionException;
88
use Illuminate\Support\Collection;
99
use Illuminate\Support\Facades\Cache;
10+
use Illuminate\Support\Facades\DB;
1011
use Illuminate\Support\Facades\Route;
1112
use Illuminate\Support\Str;
1213
use Illuminate\Validation\Rules\Password;
@@ -27,13 +28,16 @@ public static function generateConsideringCache(): Collection
2728
{
2829
$appVersion = trim(file_get_contents(base_path('version')));
2930
$cacheKey = 'api-docs::' . $appVersion;
30-
if (Cache::has($cacheKey) && config('app.env') === 'production') {
31-
$docs = Cache::get($cacheKey);
32-
} else {
33-
$docs = (new ApiDocsGenerator())->generate();
34-
Cache::put($cacheKey, $docs, 60 * 24);
31+
$isProduction = config('app.env') === 'production';
32+
$cacheVal = $isProduction ? Cache::get($cacheKey) : null;
33+
34+
if (!is_null($cacheVal)) {
35+
return $cacheVal;
3536
}
3637

38+
$docs = (new ApiDocsGenerator())->generate();
39+
Cache::put($cacheKey, $docs, 60 * 24);
40+
3741
return $docs;
3842
}
3943

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::table('cache', function (Blueprint $table) {
17+
$table->mediumText('value')->change();
18+
});
19+
}
20+
21+
/**
22+
* Reverse the migrations.
23+
*
24+
* @return void
25+
*/
26+
public function down()
27+
{
28+
Schema::table('cache', function (Blueprint $table) {
29+
$table->text('value')->change();
30+
});
31+
}
32+
};

0 commit comments

Comments
 (0)