mostafaznv /
laracache
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Mostafaznv\LaraCache\Jobs; |
||
| 4 | |||
| 5 | use Illuminate\Bus\Queueable; |
||
| 6 | use Illuminate\Contracts\Queue\ShouldQueue; |
||
| 7 | use Illuminate\Foundation\Bus\Dispatchable; |
||
| 8 | use Illuminate\Queue\InteractsWithQueue; |
||
| 9 | use Illuminate\Queue\SerializesModels; |
||
| 10 | use Illuminate\Support\Facades\Cache; |
||
| 11 | |||
| 12 | |||
| 13 | class DebounceRefresh implements ShouldQueue |
||
| 14 | { |
||
| 15 | use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 16 | |||
| 17 | public function __construct( |
||
| 18 | public string $key, |
||
| 19 | public string $token, |
||
| 20 | public string $model, |
||
| 21 | public string $name, |
||
| 22 | ) {} |
||
| 23 | |||
| 24 | |||
| 25 | public function handle(): void |
||
| 26 | { |
||
| 27 | $latestToken = Cache::get($this->key); |
||
| 28 | |||
| 29 | if ($latestToken !== $this->token) { |
||
| 30 | return; |
||
| 31 | } |
||
| 32 | |||
| 33 | app($this->model)->cache()->update($this->name); |
||
| 34 | } |
||
| 35 | } |
||
| 36 |