diff --git a/app/Jobs/Dashboard/RunActiveCountriesTableJob.php b/app/Jobs/Dashboard/RunActiveCountriesTableJob.php index 577879439..972f190e7 100644 --- a/app/Jobs/Dashboard/RunActiveCountriesTableJob.php +++ b/app/Jobs/Dashboard/RunActiveCountriesTableJob.php @@ -75,7 +75,7 @@ public function handle(RunActiveCountriesTableService $runActiveCountriesTableSe Redis::set('dashboard:active-countries-table|' . $this->cacheParameter, json_encode([ 'data' => $response, - ])); + ]), 'EX', config('cache.ttl.dashboard')); $delayedJob->update([ 'status' => DelayedJob::STATUS_SUCCEEDED, diff --git a/app/Jobs/Dashboard/RunActiveProjectsJob.php b/app/Jobs/Dashboard/RunActiveProjectsJob.php index f1b3f4781..8248a7eed 100644 --- a/app/Jobs/Dashboard/RunActiveProjectsJob.php +++ b/app/Jobs/Dashboard/RunActiveProjectsJob.php @@ -66,7 +66,7 @@ public function handle(RunActiveProjectsService $runActiveProjectsService) ] ); $response = $runActiveProjectsService->runActiveProjectsJob($request); - Redis::set('dashboard:active-projects|' . $this->cacheParameter, json_encode($response)); + Redis::set('dashboard:active-projects|' . $this->cacheParameter, json_encode($response), 'EX', config('cache.ttl.dashboard')); $delayedJob->update([ diff --git a/app/Jobs/Dashboard/RunHectaresRestoredJob.php b/app/Jobs/Dashboard/RunHectaresRestoredJob.php index 54773961e..08ee4872f 100644 --- a/app/Jobs/Dashboard/RunHectaresRestoredJob.php +++ b/app/Jobs/Dashboard/RunHectaresRestoredJob.php @@ -66,7 +66,7 @@ public function handle(RunHectaresRestoredService $runHectaresRestoredService) ] ); $response = $runHectaresRestoredService->runHectaresRestoredJob($request); - Redis::set('dashboard:indicator/hectares-restoration' . $this->cacheParameter, json_encode($response)); + Redis::set('dashboard:indicator/hectares-restoration' . $this->cacheParameter, json_encode($response), 'EX', config('cache.ttl.dashboard')); $delayedJob->update([ diff --git a/app/Jobs/Dashboard/RunJobsCreatedJob.php b/app/Jobs/Dashboard/RunJobsCreatedJob.php index 1cb7693c0..8332f67a5 100644 --- a/app/Jobs/Dashboard/RunJobsCreatedJob.php +++ b/app/Jobs/Dashboard/RunJobsCreatedJob.php @@ -72,7 +72,7 @@ public function handle(JobsCreatedService $jobsCreatedService) ]); $response = $jobsCreatedService->calculateJobsCreated($request); - Redis::set('dashboard:jobs-created|' . $this->cacheParameter, json_encode($response)); + Redis::set('dashboard:jobs-created|' . $this->cacheParameter, json_encode($response), 'EX', config('cache.ttl.dashboard')); $delayedJob->update([ 'status' => DelayedJob::STATUS_SUCCEEDED, diff --git a/app/Jobs/Dashboard/RunTopTreesJob.php b/app/Jobs/Dashboard/RunTopTreesJob.php index d877197a3..e203e656d 100644 --- a/app/Jobs/Dashboard/RunTopTreesJob.php +++ b/app/Jobs/Dashboard/RunTopTreesJob.php @@ -66,7 +66,7 @@ public function handle(RunTopTreesService $runTopTreesService) ] ); $response = $runTopTreesService->runTopTreesJob($request); - Redis::set('dashboard:top-trees-planted|' . $this->cacheParameter, json_encode($response)); + Redis::set('dashboard:top-trees-planted|' . $this->cacheParameter, json_encode($response), 'EX', config('cache.ttl.dashboard')); $delayedJob->update([ diff --git a/app/Jobs/Dashboard/RunTotalHeaderJob.php b/app/Jobs/Dashboard/RunTotalHeaderJob.php index 3546e5423..10bcba951 100644 --- a/app/Jobs/Dashboard/RunTotalHeaderJob.php +++ b/app/Jobs/Dashboard/RunTotalHeaderJob.php @@ -66,7 +66,7 @@ public function handle(RunTotalHeaderService $runTotalHeaderService) ] ); $response = $runTotalHeaderService->runTotalHeaderJob($request); - Redis::set('dashboard:total-section-header|' . $this->cacheParameter, json_encode($response)); + Redis::set('dashboard:total-section-header|' . $this->cacheParameter, json_encode($response), 'EX', config('cache.ttl.dashboard')); $delayedJob->update([ 'status' => DelayedJob::STATUS_SUCCEEDED, diff --git a/app/Jobs/Dashboard/RunTreeRestorationGoalJob.php b/app/Jobs/Dashboard/RunTreeRestorationGoalJob.php index d073db742..45ec90257 100644 --- a/app/Jobs/Dashboard/RunTreeRestorationGoalJob.php +++ b/app/Jobs/Dashboard/RunTreeRestorationGoalJob.php @@ -72,7 +72,7 @@ public function handle(TreeRestorationGoalService $treeRestorationGoalService) ]); $response = $treeRestorationGoalService->calculateTreeRestorationGoal($request); - Redis::set('dashboard:tree-restoration-goal|' . $this->cacheParameter, json_encode($response)); + Redis::set('dashboard:tree-restoration-goal|' . $this->cacheParameter, json_encode($response), 'EX', config('cache.ttl.dashboard')); $delayedJob->update([ 'status' => DelayedJob::STATUS_SUCCEEDED, diff --git a/app/Jobs/Dashboard/RunVolunteersAverageJob.php b/app/Jobs/Dashboard/RunVolunteersAverageJob.php index 724a073bd..2582b5838 100644 --- a/app/Jobs/Dashboard/RunVolunteersAverageJob.php +++ b/app/Jobs/Dashboard/RunVolunteersAverageJob.php @@ -66,7 +66,7 @@ public function handle(RunVolunteersAverageService $runVolunteersAverageService) ] ); $response = $runVolunteersAverageService->runVolunteersAverageJob($request); - Redis::set('dashboard:volunteers-survival-rate|' . $this->cacheParameter, json_encode($response)); + Redis::set('dashboard:volunteers-survival-rate|' . $this->cacheParameter, json_encode($response), 'EX', config('cache.ttl.dashboard')); $delayedJob->update([ diff --git a/config/cache.php b/config/cache.php index b82efddc6..56d9a8da2 100644 --- a/config/cache.php +++ b/config/cache.php @@ -107,4 +107,18 @@ 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'), + /* + |-------------------------------------------------------------------------- + | Cache Timeout Values + |-------------------------------------------------------------------------- + | + | Here you may define the cache timeout values for different sections + | of the application. These values can be used in any controllers + | to set the time-to-live (TTL) for cached items. + | + */ + + 'ttl' => [ + 'dashboard' => 86400, // 24 hours + ] ];