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