Restore cache clearing functionality

This commit is contained in:
Timothy Warren 2017-01-16 11:26:19 -05:00
parent d79370deb9
commit a266c68f9b
5 changed files with 21 additions and 11 deletions

View File

@ -17,13 +17,13 @@
[<a href="<?= $urlGenerator->default_url('manga') ?>">Manga List</a>] [<a href="<?= $urlGenerator->default_url('manga') ?>">Manga List</a>]
<?php endif ?> <?php endif ?>
</span> </span>
<?php /* if ($auth->is_authenticated()): ?> <?php if ($auth->is_authenticated()): ?>
<span class="flex-no-wrap">&nbsp;</span> <span class="flex-no-wrap">&nbsp;</span>
<span class="flex-no-wrap small-font"> <span class="flex-no-wrap small-font">
<button type="button" class="js-clear-cache user-btn">Clear API Cache</button> <button type="button" class="js-clear-cache user-btn">Clear API Cache</button>
</span> </span>
<span class="flex-no-wrap">&nbsp;</span> <span class="flex-no-wrap">&nbsp;</span>
<?php endif */ ?> <?php endif ?>
<span class="flex-no-wrap small-font"> <span class="flex-no-wrap small-font">
<?php if ($auth->is_authenticated()): ?> <?php if ($auth->is_authenticated()): ?>
<a class="bracketed" href="<?= $url->generate('logout') ?>">Logout</a> <a class="bracketed" href="<?= $url->generate('logout') ?>">Logout</a>

View File

@ -41,6 +41,16 @@ trait CacheTrait {
return $this; 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 * Generate a hash as a cache key from the current method call
* *

View File

@ -374,7 +374,7 @@ class Controller {
*/ */
public function clearCache() public function clearCache()
{ {
$this->cache->purge(); $this->cache->clear();
$this->outputHTML('blank', [ $this->outputHTML('blank', [
'title' => 'Cache cleared' 'title' => 'Cache cleared'
], NULL, 200); ], NULL, 200);

View File

@ -159,7 +159,7 @@ class Anime extends BaseController {
if ($result) if ($result)
{ {
$this->set_flash_message('Added new anime to list', 'success'); $this->set_flash_message('Added new anime to list', 'success');
// $this->cache->purge(); $this->cache->clear();
} }
else else
{ {
@ -233,7 +233,7 @@ class Anime extends BaseController {
if ($full_result['statusCode'] === 200) if ($full_result['statusCode'] === 200)
{ {
$this->set_flash_message("Successfully updated.", 'success'); $this->set_flash_message("Successfully updated.", 'success');
// $this->cache->purge(); $this->cache->clear();
} }
else else
{ {
@ -261,7 +261,7 @@ class Anime extends BaseController {
$response = $this->model->updateLibraryItem($data); $response = $this->model->updateLibraryItem($data);
// $this->cache->purge(); $this->cache->clear();
$this->outputJSON($response['body'], $response['statusCode']); $this->outputJSON($response['body'], $response['statusCode']);
} }
@ -278,7 +278,7 @@ class Anime extends BaseController {
if ((bool)$response === TRUE) if ((bool)$response === TRUE)
{ {
$this->set_flash_message("Successfully deleted anime.", 'success'); $this->set_flash_message("Successfully deleted anime.", 'success');
// $this->cache->purge(); $this->cache->clear();
} }
else else
{ {

View File

@ -142,7 +142,7 @@ class Manga extends Controller {
if ($result) if ($result)
{ {
$this->set_flash_message('Added new manga to list', 'success'); $this->set_flash_message('Added new manga to list', 'success');
// $this->cache->purge(); $this->cache->clear();
} }
else else
{ {
@ -203,7 +203,7 @@ class Manga extends Controller {
if ($full_result['statusCode'] === 200) if ($full_result['statusCode'] === 200)
{ {
$this->set_flash_message("Successfully updated manga.", 'success'); $this->set_flash_message("Successfully updated manga.", 'success');
// $this->cache->purge(); $this->cache->clear();
} }
else else
{ {
@ -232,7 +232,7 @@ class Manga extends Controller {
$response = $this->model->updateLibraryItem($data); $response = $this->model->updateLibraryItem($data);
// $this->cache->purge(); $this->cache->clear();
$this->outputJSON($response['body'], $response['statusCode']); $this->outputJSON($response['body'], $response['statusCode']);
} }
@ -250,7 +250,7 @@ class Manga extends Controller {
if ($response) if ($response)
{ {
$this->set_flash_message("Successfully deleted manga.", 'success'); $this->set_flash_message("Successfully deleted manga.", 'success');
//$this->cache->purge(); $this->cache->clear();
} }
else else
{ {