Skip to content
PromptPilot AI

Library / Coding & Technology / Performance

Laravel: move slow work to a queued job

Idempotent jobs with retries and tests.

Cursor / coding agentsClaude CodeChatGPTClaudelaravel
Who it's for
Developers using AI coding tools
Use case
Performance
Output
Agent task · Free
You'll need to fill in
slow work, e.g. sending invoice PDF email
Prevents: Job is not idempotent, so retries send duplicate emails or charges.
Move [slow work, e.g. sending invoice PDF email] from the request cycle into a queued job.
- Make the job idempotent (safe to run twice).
- Set sensible $tries, backoff and timeout; handle failure in failed().
- Pass IDs, not whole models with large relations, unless using SerializesModels intentionally.
- Use Queue::fake() / Bus::fake() in tests to assert dispatch, and a separate test for the job's handle().
Explain how to run the worker locally.

Copies your prompt and opens the official site in a new tab. You may need to paste it yourself (Ctrl/⌘ + V). Nothing is sent to the AI by us.

Replace [bracketed] parts with your own details before sending. Want it tailored? Build a custom website & app development prompt.

Before vs after

A typical one-line request compared with this prompt. We only show sample responses where we've written an illustration.

BeforeWhat people usually type

Prompt

performance

1 words · no role, context, format or constraints

AfterThis library prompt

Prompt

Move [slow work, e.g. sending invoice PDF email] from the request cycle into a queued job.
- Make the job idempotent (safe to run twice).
- Set sensible $tries, backoff and timeout; handle failure in failed().
- Pass IDs, not whole models with large relations, unless using SerializesModels intentionally.
- Use Queue::fake() / Bus::fake() in tests to assert dispatch, and a separate test for the job's handle().
Explain how to run the worker locally.

74 words · generated instantly from templates, no AI called

What we added

  • Your details: [brackets] for the facts only you know

Related prompts