aiblog/app/Listeners/ClearPostCache.php
2024-11-17 11:30:01 +08:00

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();
}
}