cache->get($slug); if ($data === null) { // Cache miss — try DB $link = Link::where('slug', $slug) ->whereNull('domain_id') ->first(); if (! $link) { abort(404); } $this->cache->warmFromLink($link); $data = $this->cache->get($slug); } // 2. Status check if (($data['status'] ?? '') !== 'active') { abort(410); } // 3. Expiry check $expiresAt = $data['expires_at'] ?? ''; if ($expiresAt !== '' && (int) $expiresAt < time()) { abort(410); } // 4. RecordClickJob dispatched in Task 7 RecordClickJob::dispatch( (int) $data['link_id'], $request->ip() ?? '', $request->userAgent() ?? '', $request->headers->all(), $request->query(), )->onQueue('clicks'); // 5. 302 redirect return redirect($data['target'], 302); } }