How to use StaticPublishQueue

silverstripe-4
Tags: #<Tag:0x00007f10ce349ed8>

#1

Silverstripe Version: 4.2.1

Question: How to cache a bunch of URLs NOW

I loved the old Modul. It was easy to use and had a great Performance. Now everything sucks. There is’nt even a Queue anymore. How can I just easyly cache some URLs like before?
Why does StaticCacheFullBuildTask takes more than 2GB of Ram? And why is it just one unbreakable Task that makes my Priorities useless?
Is it possible to get saticpublishqueue V3 to work on SS4?

$urls = array("/" => 80);
			$urls = array_merge((array)$urls, array("/jsonapi/ticker" => 85));
			$urls = array_merge((array)$urls, array("/jsonapi/ticker/current" => 85));
			$urls = array_merge((array)$urls, array("/jsonapi/ticker/".$this->game->ID => 85));
			$urls = array_merge((array)$urls, array("/jsonapi/game/current" => 80));
			$urls = array_merge((array)$urls, array("/jsonapi/game/".$this->game->ID => 80));
			$urls = array_merge((array)$urls, array("/jsonapi/matchday/".$this->game->competitionID."/".$this->game->dayNumber => 80));
			$urls = array_merge((array)$urls, array("/jsonapi_en/ticker" => 85));
			$urls = array_merge((array)$urls, array("/jsonapi_en/ticker/current" => 85));
			$urls = array_merge((array)$urls, array("/jsonapi_en/ticker/".$this->game->ID => 85));
			$urls = array_merge((array)$urls, array("/jsonapi_en/game/current" => 80));
			$urls = array_merge((array)$urls, array("/jsonapi_en/game/".$this->game->ID => 80));
			$urls = array_merge((array)$urls, array("/jsonapi_en/matchday/".$this->game->competitionID."/".$this->game->dayNumber => 80));
			$urls = array_merge((array)$urls, array("/matchcenter" => 80));
			$urls = array_merge((array)$urls, array("/matchcenter/show/".$this->game->ID => 80));
			$urls = array_merge((array)$urls, array("/matchcenter/callHeader/".$this->game->ID => 90));
			$urls = array_merge((array)$urls, array("/matchcenter/callTicker/".$this->game->ID => 85));
			$urls = array_merge((array)$urls, array("/matchcenter/callGameday/".$this->game->ID => 80));
			$urls = array_merge((array)$urls, array("/matchcenter/callNomination/".$this->game->ID => 80));
			$urls = array_merge((array)$urls, array("/matchcenter/callOpponent/".$this->game->ID => 80));
			$obj = new URLArrayObject();
			$obj->addUrls($urls);

Rel: staticpublishque there is no queue


#2

What I did now:

$queue = QueuedJobService::singleton();
			$job = Injector::inst()->create(GenerateStaticCacheJob::class);
					
			$jobData = new \stdClass();
			ksort($urls);
			$jobData->URLsToProcess = $urls;
			$job->setJobData(0, 0, false, $jobData, [
				'Building URLs: ' . var_export(array_keys($jobData->URLsToProcess), true)
			]);
			$queue->queueJob($job);

Now I’ve a Job. That caches my set of URLs and when it’s done It switches to status “waiting” till I call dev/tasks/ProcessJobQueueTask again it swiches back to “running” but doesen’t do anything anymore. It never gets fishished.


#3

It’s the URLs of my custom Controller that not get cached and leading my job to never complete.
[SOLVED] I Had to call my custom Controller via CLI. Like this:
./vendor/bin/sake /jsonapi/ticker/current flush=all

Now its caching. However in GenerateStaticCacheJob.php if a URL returns [responsecode] => 404 it should lead to status = Broken, but it doesn’t