File tree Expand file tree Collapse file tree 2 files changed +41
-5
lines changed
Expand file tree Collapse file tree 2 files changed +41
-5
lines changed Original file line number Diff line number Diff line change 77use Illuminate \Contracts \Container \BindingResolutionException ;
88use Illuminate \Support \Collection ;
99use Illuminate \Support \Facades \Cache ;
10+ use Illuminate \Support \Facades \DB ;
1011use Illuminate \Support \Facades \Route ;
1112use Illuminate \Support \Str ;
1213use 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
Original file line number Diff line number Diff line change 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+ };
You can’t perform that action at this time.
0 commit comments