- Add predis/predis for Redis support - Configure cache/queue defaults to redis in config + .env.example - Create DashboardController with 60s cache for dashboard queries - Add cache (5min) to ReportController::generate() and preview() - Add FeatureObserver, InspectionObserver, IssueObserver for cache invalidation - Fix N+1 in ProjectMap (eager load template, images), TaskManager (subtasks.parentTask) - Register observers in AppServiceProvider Tests: 101 passing (319 assertions)
26 lines
559 B
PHP
26 lines
559 B
PHP
<?php
|
|
|
|
namespace App\Observers;
|
|
|
|
use App\Models\Inspection;
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
class InspectionObserver
|
|
{
|
|
public function saved(Inspection $inspection): void
|
|
{
|
|
$this->clearReportCache($inspection->project_id);
|
|
}
|
|
|
|
public function deleted(Inspection $inspection): void
|
|
{
|
|
$this->clearReportCache($inspection->project_id);
|
|
}
|
|
|
|
private function clearReportCache(?int $projectId): void
|
|
{
|
|
if ($projectId) {
|
|
Cache::tags(["report:project:{$projectId}"])->flush();
|
|
}
|
|
}
|
|
} |