From a266c68f9b42a3bb769f16715cf2f419f8de77d7 Mon Sep 17 00:00:00 2001 From: Timothy J Warren Date: Mon, 16 Jan 2017 11:26:19 -0500 Subject: [PATCH] Restore cache clearing functionality --- app/views/main-menu.php | 4 ++-- src/API/CacheTrait.php | 10 ++++++++++ src/Controller.php | 2 +- src/Controller/Anime.php | 8 ++++---- src/Controller/Manga.php | 8 ++++---- 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/app/views/main-menu.php b/app/views/main-menu.php index 6f3b99f9..3e0111ca 100644 --- a/app/views/main-menu.php +++ b/app/views/main-menu.php @@ -17,13 +17,13 @@ [Manga List] - is_authenticated()): ?> + is_authenticated()): ?>     - + is_authenticated()): ?> Logout diff --git a/src/API/CacheTrait.php b/src/API/CacheTrait.php index 6ce11410..211c3977 100644 --- a/src/API/CacheTrait.php +++ b/src/API/CacheTrait.php @@ -41,6 +41,16 @@ trait CacheTrait { return $this; } + /** + * Get the cache object if it exists + * + * @return Pool + */ + public function getCache() + { + return $this->cache; + } + /** * Generate a hash as a cache key from the current method call * diff --git a/src/Controller.php b/src/Controller.php index 708e1984..91148358 100644 --- a/src/Controller.php +++ b/src/Controller.php @@ -374,7 +374,7 @@ class Controller { */ public function clearCache() { - $this->cache->purge(); + $this->cache->clear(); $this->outputHTML('blank', [ 'title' => 'Cache cleared' ], NULL, 200); diff --git a/src/Controller/Anime.php b/src/Controller/Anime.php index 674171a4..455921a0 100644 --- a/src/Controller/Anime.php +++ b/src/Controller/Anime.php @@ -159,7 +159,7 @@ class Anime extends BaseController { if ($result) { $this->set_flash_message('Added new anime to list', 'success'); - // $this->cache->purge(); + $this->cache->clear(); } else { @@ -233,7 +233,7 @@ class Anime extends BaseController { if ($full_result['statusCode'] === 200) { $this->set_flash_message("Successfully updated.", 'success'); - // $this->cache->purge(); + $this->cache->clear(); } else { @@ -261,7 +261,7 @@ class Anime extends BaseController { $response = $this->model->updateLibraryItem($data); - // $this->cache->purge(); + $this->cache->clear(); $this->outputJSON($response['body'], $response['statusCode']); } @@ -278,7 +278,7 @@ class Anime extends BaseController { if ((bool)$response === TRUE) { $this->set_flash_message("Successfully deleted anime.", 'success'); - // $this->cache->purge(); + $this->cache->clear(); } else { diff --git a/src/Controller/Manga.php b/src/Controller/Manga.php index 96cc2959..08d93c87 100644 --- a/src/Controller/Manga.php +++ b/src/Controller/Manga.php @@ -142,7 +142,7 @@ class Manga extends Controller { if ($result) { $this->set_flash_message('Added new manga to list', 'success'); - // $this->cache->purge(); + $this->cache->clear(); } else { @@ -203,7 +203,7 @@ class Manga extends Controller { if ($full_result['statusCode'] === 200) { $this->set_flash_message("Successfully updated manga.", 'success'); - // $this->cache->purge(); + $this->cache->clear(); } else { @@ -232,7 +232,7 @@ class Manga extends Controller { $response = $this->model->updateLibraryItem($data); - // $this->cache->purge(); + $this->cache->clear(); $this->outputJSON($response['body'], $response['statusCode']); } @@ -250,7 +250,7 @@ class Manga extends Controller { if ($response) { $this->set_flash_message("Successfully deleted manga.", 'success'); - //$this->cache->purge(); + $this->cache->clear(); } else {