Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TM-1586] set cache timeout for dashboard endpoints #636

Merged
merged 1 commit into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Jobs/Dashboard/RunActiveCountriesTableJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion app/Jobs/Dashboard/RunActiveProjectsJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down
2 changes: 1 addition & 1 deletion app/Jobs/Dashboard/RunHectaresRestoredJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down
2 changes: 1 addition & 1 deletion app/Jobs/Dashboard/RunJobsCreatedJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion app/Jobs/Dashboard/RunTopTreesJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down
2 changes: 1 addition & 1 deletion app/Jobs/Dashboard/RunTotalHeaderJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion app/Jobs/Dashboard/RunTreeRestorationGoalJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion app/Jobs/Dashboard/RunVolunteersAverageJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down
14 changes: 14 additions & 0 deletions config/cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
];
Loading