Version 5.1 - All the GraphQL #32

Closed
timw4mail wants to merge 1160 commits from develop into master
3 changed files with 16 additions and 5 deletions
Showing only changes of commit 1fd2dd1146 - Show all commits

View File

@ -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();

View File

@ -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())
{ {

View File

@ -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.');
} }
} }