diff --git a/.github/workflows/test-cc.yml b/.github/workflows/test-cc.yml index 2424a33..16487b0 100644 --- a/.github/workflows/test-cc.yml +++ b/.github/workflows/test-cc.yml @@ -55,17 +55,18 @@ jobs: - name: codecov upload uses: codecov/codecov-action@v1 - - name: Setup Code Climate test-reporter - run: | - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter - chmod +x ./cc-test-reporter - - name: SafeDirFix - run: git config --global safe.directory '*' - - - name: Convert - run: ./cc-test-reporter format-coverage coverage.xml -t clover -o codeclimate.0.json - - - name: Upload - run: ./cc-test-reporter upload-coverage -i codeclimate.0.json - env: - CC_TEST_REPORTER_ID: 004a62af5e00aac588594d19de2be2e6c6d0844332c6a5a4f54b7fdfb00e0798 +# - name: Setup Code Climate test-reporter +# run: | +# curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter +# chmod +x ./cc-test-reporter +# - name: SafeDirFix +# run: git config --global safe.directory '*' +# +# - name: Convert +# shell: bash +# run: ./cc-test-reporter format-coverage coverage.xml -t clover -o codeclimate.0.json +# +# - name: Upload +# run: ./cc-test-reporter upload-coverage -i codeclimate.0.json +# env: +# CC_TEST_REPORTER_ID: 004a62af5e00aac588594d19de2be2e6c6d0844332c6a5a4f54b7fdfb00e0798 diff --git a/src/Enum/ConstantEnum.php b/src/Enum/ConstantEnum.php index 5289a09..78dedaf 100644 --- a/src/Enum/ConstantEnum.php +++ b/src/Enum/ConstantEnum.php @@ -8,4 +8,6 @@ class ConstantEnum extends Enum { public const PER_PAGE = 15; public const DIRECTORY = 'consultation'; + public const REDIS_IMAGES_KEY = 'signed_urls_index'; + public const REDIS_IMAGES_TTL = 300; } diff --git a/src/Services/ConsultationService.php b/src/Services/ConsultationService.php index 2efc696..a18e327 100644 --- a/src/Services/ConsultationService.php +++ b/src/Services/ConsultationService.php @@ -51,6 +51,7 @@ use Illuminate\Http\UploadedFile; use Illuminate\Support\Collection; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Redis; use Illuminate\Support\Facades\Storage; use Illuminate\Support\Str; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; @@ -631,6 +632,13 @@ public function generateSignedScreenUrls(GenerateSignedScreenUrlsDto $dto): arra return array_map(function ($file) use ($directory) { $filename = $file['filename']; + if (config('cache.default') === 'redis') { + $key = 'signed_urls:' . md5($directory . $filename); + Redis::command('SETEX', [$key, ConstantEnum::REDIS_IMAGES_TTL, $directory . $filename]); + Redis::command('HSET', [ConstantEnum::REDIS_IMAGES_KEY, $key, 1]); + Redis::command('EXPIRE', [ConstantEnum::REDIS_IMAGES_KEY, ConstantEnum::REDIS_IMAGES_TTL]); + } + return array_merge( ['filename' => $filename], Storage::temporaryUploadUrl($directory . $filename, now()->addMinutes(5))