Skip to content

Instantly share code, notes, and snippets.

@rmcdaniel
Created November 15, 2022 15:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rmcdaniel/1d472e4968ba9fbc32466e262c9b1f32 to your computer and use it in GitHub Desktop.
Save rmcdaniel/1d472e4968ba9fbc32466e262c9b1f32 to your computer and use it in GitHub Desktop.
<?php
namespace App\Workflows\InvalidateCache;
use Workflow\ActivityStub;
use Workflow\Workflow;
use Workflow\WorkflowStub;
class InvalidateCacheWorkflow extends Workflow
{
public function execute($url)
{
$oldDate = yield ActivityStub::make(CheckImageDateActivity::class, $url);
while (true) {
yield ActivityStub::make(InvalidateCacheActivity::class, $url);
for ($i = 0; $i < 3; ++$i) {
yield WorkflowStub::timer(30);
$newDate = yield ActivityStub::make(CheckImageDateActivity::class, $url);
if ($oldDate !== $newDate) return;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment