Created
November 15, 2022 15:02
-
-
Save rmcdaniel/1d472e4968ba9fbc32466e262c9b1f32 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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