Fix syntax error, prime manga cache too. See #19
This commit is contained in:
parent
53b8ce44bf
commit
74602f60fa
4
console
4
console
@ -35,9 +35,9 @@ unset($CONF_DIR);
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
$console = new \ConsoleKit\Console([
|
||||
'cache-prime' => '\Aviat\AnimeClient\Command\CachePrime',
|
||||
'cache-clear' => '\Aviat\AnimeClient\Command\CacheClear'
|
||||
'cache-clear' => '\Aviat\AnimeClient\Command\CacheClear',
|
||||
'clear-cache' => '\Aviat\AnimeClient\Command\CacheClear',
|
||||
'sync-lists' => '\Aviat\AnimeClient\Command\SyncKitsuWithMal'
|
||||
'sync-lists' => '\Aviat\AnimeClient\Command\SyncKitsuWithMal',
|
||||
]);
|
||||
|
||||
$console->run();
|
@ -69,6 +69,11 @@ trait KitsuTrait {
|
||||
if ($sessionSegment->get('auth_token') !== NULL && $url !== K::AUTH_URL)
|
||||
{
|
||||
$token = $sessionSegment->get('auth_token');
|
||||
if ( ! $cacheItem->isHit())
|
||||
{
|
||||
$cacheItem->set($token);
|
||||
$cacheItem->save();
|
||||
}
|
||||
}
|
||||
else if ($sessionSegment->get('auth_token') === NULL && $cacheItem->isHit())
|
||||
{
|
||||
|
@ -32,14 +32,16 @@ class CachePrime extends BaseCommand {
|
||||
{
|
||||
$this->setContainer($this->setupContainer());
|
||||
|
||||
$cache = $container->get('cache');
|
||||
$cache = $this->container->get('cache');
|
||||
|
||||
// Save the user id, if it exists, for priming the cache
|
||||
$userIdItem = $cache->getItem('kitsu-auth-token');
|
||||
$userId = $userIdItem->isHit() ? $userIdItem->get : null;
|
||||
$userId = $userIdItem->isHit() ? $userIdItem->get() : null;
|
||||
|
||||
$cache->clear();
|
||||
|
||||
$this->echoBox('Cache cleared, re-priming...');
|
||||
|
||||
if ( ! is_null($userId))
|
||||
{
|
||||
$userIdItem = $cache->getItem('kitsu-auth-token');
|
||||
@ -47,9 +49,13 @@ class CachePrime extends BaseCommand {
|
||||
$userIdItem->save();
|
||||
}
|
||||
|
||||
$kitsuModel = $container->get('kitsu-model');
|
||||
// Prime anime list cache
|
||||
$kitsuModel = $this->container->get('kitsu-model');
|
||||
$kitsuModel->getFullOrganizedAnimeList();
|
||||
|
||||
// Prime manga list cache
|
||||
$kitsuModel->getFullOrganizedMangaList();
|
||||
|
||||
$this->echoBox('API Cache has been primed.');
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user