Files
SkinbaseNova/app/Jobs/RegenerateUserRecommendationCacheJob.php
2026-02-14 15:14:12 +01:00

48 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Jobs;
use App\Services\Recommendations\PersonalizedFeedService;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
final class RegenerateUserRecommendationCacheJob implements ShouldQueue
{
use Dispatchable;
use InteractsWithQueue;
use Queueable;
use SerializesModels;
public int $tries = 3;
/** @var array<int, int> */
public array $backoff = [10, 60, 180];
public function __construct(
public readonly int $userId,
public readonly string $algoVersion
) {
}
public function handle(PersonalizedFeedService $feedService): void
{
try {
$feedService->regenerateCacheForUser($this->userId, $this->algoVersion);
} catch (\Throwable $e) {
Log::error('RegenerateUserRecommendationCacheJob failed', [
'user_id' => $this->userId,
'algo_version' => $this->algoVersion,
'error' => $e->getMessage(),
]);
throw $e;
}
}
}