22 lines
No EOL
426 B
PHP
22 lines
No EOL
426 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Listeners;
|
|
|
|
use App\Events\PostCreated;
|
|
use App\Events\PostUpdated;
|
|
use App\Services\CacheService;
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
class ClearPostCache
|
|
{
|
|
public function __construct(
|
|
protected CacheService $cacheService
|
|
) {}
|
|
|
|
public function handle(PostCreated|PostUpdated $event): void
|
|
{
|
|
Cache::tags(['posts', 'search'])->flush();
|
|
}
|
|
}
|