Skip to content

Commit 1148b1c

Browse files
committed
Document failed jobs and other things.
1 parent 88eff06 commit 1148b1c

File tree

4 files changed

+61
-0
lines changed

4 files changed

+61
-0
lines changed

cache.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ The cache configuration file also contains various other options, which are docu
3030

3131
Cache::add('key', 'value', $minutes);
3232

33+
The `add` method will return `true` if the item is actually **added** to the cache. Otherwise, the method will return `false`.
34+
3335
**Checking For Existence In Cache**
3436

3537
if (Cache::has('key'))

pagination.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ This will generate URLs that look something like this:
8282

8383
http://example.com/something?page=2&sort=votes
8484

85+
If you wish to append a "hash fragment" to the paginator's URLs, you may use the `fragment` method:
86+
87+
<?php echo $users->fragment('foo')->links(); ?>
88+
89+
This method call will generate URLs that look something like this:
90+
91+
http://example.com/something?page=2#foo
92+
8593
<a name="converting-to-json"></a>
8694
## Converting To JSON
8795

queries.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- [Updates](#updates)
1111
- [Deletes](#deletes)
1212
- [Unions](#unions)
13+
- [Pessimistic Locking](#pessimistic-locking)
1314
- [Caching Queries](#caching-queries)
1415

1516
<a name="introduction"></a>
@@ -281,6 +282,19 @@ The query builder also provides a quick way to "union" two queries together:
281282

282283
The `unionAll` method is also available, and has the same method signature as `union`.
283284

285+
<a name="pessimistic-locking"></a>
286+
## Pessimistic Locking
287+
288+
The query builder includes a few functions to help you do "pessimistic locking" on your SELECT statements.
289+
290+
To run the SELECT statement with a "shared lock", you may use the `sharedLock` method on a query:
291+
292+
DB::table('users')->where('votes', '>', 100)->sharedLock()->get();
293+
294+
To "lock for update" on a SELECT statement, you may use the `lockForUpdate` method on a query:
295+
296+
DB::table('users')->where('votes', '>', 100)->lockForUpdate()->get();
297+
284298
<a name="caching-queries"></a>
285299
## Caching Queries
286300

queues.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- [Queueing Closures](#queueing-closures)
66
- [Running The Queue Listener](#running-the-queue-listener)
77
- [Push Queues](#push-queues)
8+
- [Failed Jobs](#failed-jobs)
89

910
<a name="configuration"></a>
1011
## Configuration
@@ -184,3 +185,39 @@ Now, when you login to your Iron dashboard, you will see your new push queue, as
184185
});
185186

186187
The `marshal` method will take care of firing the correct job handler class. To fire jobs onto the push queue, just use the same `Queue::push` method used for conventional queues.
188+
189+
<a name="failed-jobs"></a>
190+
## Failed Jobs
191+
192+
Since things don't always go as planned, sometimes your queued jobs will fail. Don't worry, it happens to the best of us! Laravel includes a convenient way to specify the maximum number of times a job should be attempted. After a job has exceeded this amount of attempts, it will be inserted into a `failed_jobs` table. The failed jobs table name can be configured via the `app/config/queue.php` configuration file.
193+
194+
To create a migration for the `failed_jobs` table, you may use the `queue:failed-table` command:
195+
196+
php artisan queue:failed-table
197+
198+
You can specify the maximum number of times a job should be attempted using the `--tries` switch on the `queue:listen` command:
199+
200+
php artisan queue:listen connection-name --tries=3
201+
202+
If you would like to register an event that will be called when a queue job fails, you may use the `Queue::failing` method. This event is a great opportunity to notify your team via e-mail or [HipChat](https://www.hipchat.com).
203+
204+
Queue::failing(function($job, $data)
205+
{
206+
//
207+
});
208+
209+
To view all of your failed jobs, you may use the `queue:failed` Artisan command:
210+
211+
php artisan queue:failed
212+
213+
The `queue:failed` command will list the job ID, connection, queue, and failure time. The job ID may be used to retry the failed job. For instance, to retry a failed job that has an ID of 5, the following command should be issued:
214+
215+
php artisan queue:retry 5
216+
217+
If you would like to delete a failed job, you may use the `queue:forget` command:
218+
219+
php artisan queue:forget 5
220+
221+
To delete all of your failed jobs, you may use the `queue:flush` command:
222+
223+
php artisan queue:flush

0 commit comments

Comments
 (0)