key($kind, $year, $month, $unit, $employeeType), $load); } public function forget(int|string $year, int|string $month, mixed $unit): void { foreach (['', 'dosen', 'tendik', 'jtt', 'jtt-univ'] as $type) { foreach (['main', 'selisih', 'perbandingan'] as $kind) { Cache::forget($this->key($kind, $year, $month, $unit, $type)); } } } public function refresh(int|string $year, int|string $month, mixed $unit, string $employeeType, Closure $main, Closure $selisih): void { // Keep the previous snapshot intact if an upstream request fails. $mainData = $main(); $selisihData = $selisih(); $this->forget($year, $month, $unit); Cache::forever($this->key('main', $year, $month, $unit, $employeeType), $mainData); Cache::forever($this->key('selisih', $year, $month, $unit, $employeeType), $selisihData); } }