summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhorus2022-11-11 17:12:43 +0100
committerhorus2022-11-11 17:12:43 +0100
commit5efc1a6d6662044badb8cdfa3c2c413a1aa161f5 (patch)
treea195f9e538d4cb94bd90242dd4c4a878408f75a6
parentae1609c2e4bac989e8d49334e2879639dc7d5be1 (diff)
downloadsenpai-5efc1a6d6662044badb8cdfa3c2c413a1aa161f5.tar.gz
try to catch exception when redis is down
-rw-r--r--app/Http/Controllers/AnimeController.php31
1 files changed, 27 insertions, 4 deletions
diff --git a/app/Http/Controllers/AnimeController.php b/app/Http/Controllers/AnimeController.php
index 47ca16b..dc6a352 100644
--- a/app/Http/Controllers/AnimeController.php
+++ b/app/Http/Controllers/AnimeController.php
@@ -6,6 +6,7 @@ use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
+use Illuminate\Support\Facades\Log;
use App\Anime;
use App\AnimeStats;
@@ -20,8 +21,12 @@ class AnimeController extends Controller {
*/
public function showAnime($mal_id, $slug = "") {
- if ( Cache::has($mal_id) ) {
- return Cache::get($mal_id);
+ try {
+ if ( Cache::has($mal_id) ) {
+ return Cache::get($mal_id);
+ }
+ } catch ( Exception $e ) {
+ Log::info( $e->getMessage() );
}
$anime = Anime::where('mal_id', $mal_id)->get()->first();
@@ -123,15 +128,29 @@ class AnimeController extends Controller {
$cached_data = view('anime', [ "anime" => $anime ])->render();
- Cache::put($mal_id, $cached_data, 6000); // 1000 minutes
+ try {
+ Cache::put($mal_id, $cached_data, 6000); // 1000 minutes
+ } catch ( Exception $e ) {
+ Log::info( $e->getMessage() );
+ }
+
return $cached_data;
}
public function showCurrentAnime() {
+ try {
+ if ( Cache::has('airing_anime') ) {
+ return Cache::get('airing_anime');
+ }
+ } catch ( Exception $e ) {
+ Log::alert( $e->getMessage() );
+ }
+ /*
if ( Cache::has('airing_anime') ) {
return Cache::get('airing_anime');
}
+ */
$anime = new Anime;
$anime = $anime->setTable('view_anime_index');
@@ -152,7 +171,11 @@ class AnimeController extends Controller {
$cached_data = view('list_anime', ["all_anime" => $anime, "title" => "Currently Airing"])->render();
- Cache::put('airing_anime', $cached_data, 6000); // 100 minutes
+ try {
+ Cache::put('airing_anime', $cached_data, 6000); // 100 minutes
+ } catch ( Exception $e ) {
+ Log::alert( $e->getMessage() );
+ }
return $cached_data;
}