Skip to content

Commit c2b6cd2

Browse files
committed
Add Queues docs
1 parent 80dd8e7 commit c2b6cd2

File tree

1 file changed

+34
-0
lines changed
  • resources/views/docs/1/digging-deeper

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
title: Queues
3+
order: 500
4+
---
5+
# Queues
6+
7+
Queueing tasks to be run in the background is a critical part of creating a great user experience.
8+
9+
NativePHP has built-in support for Laravel's [Queues](https://laravel.com/docs/queues).
10+
11+
## Queueing a job
12+
If you're familiar with queueing jobs in Laravel, you should feel right at home. There's nothing special you need to do.
13+
14+
Jobs live in the SQLite [database](/docs/digging-deeper/databases) that your app uses by default and the `jobs` table
15+
migration will have been created and migrated for you.
16+
17+
## Processing Jobs / Working the Queue
18+
When your application boots up, NativePHP starts a single queue worker, ready to process any jobs you send its way.
19+
20+
There's nothing more required.
21+
22+
In the context of your user's device, it's very rare that you would need multiple queues or many workers, as your
23+
application is likely to only be used by one user at a time.
24+
25+
## When to Queue
26+
Given that your database and application typically exist on the same machine (i.e. there's no network involved),
27+
queueing background tasks can mostly be left for very intense operations and when making API calls over the network.
28+
29+
Even so, you may find it more user-friendly to have slow tasks complete in the main application thread. You may simply
30+
choose to have your UI indicate that something is occurring (e.g. with a loading spinner) while the user waits for the
31+
process to finish.
32+
33+
This may be clearer for the user and easier to handle in case issues arise, as you can provide visual feedback to the
34+
user and they can try again more easily.

0 commit comments

Comments
 (0)