From 741b9562b0689cde175d33b2a0f72bd11fd04528 Mon Sep 17 00:00:00 2001 From: Jonas Boserup Date: Fri, 21 Mar 2025 11:39:09 +0100 Subject: [PATCH 1/2] Add schedule useCache example --- scheduling.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scheduling.md b/scheduling.md index a335055b62b..5299ce13863 100644 --- a/scheduling.md +++ b/scheduling.md @@ -388,6 +388,17 @@ Schedule::call(fn () => User::resetApiRequestCount()) ->onOneServer(); ``` + +#### Customizing the Cache Driver +If you need to override the default cache driver used for scheduling's atomic mutex locks, you can chain the `useCache` method after `onOneServer`. This allows you to specify a different cache driver (e.g. `'database'`) for the mutex without changing your application's primary cache configuration: + +```php +Schedule::command('recipes:sync') + ->everyThirtyMinutes() + ->onOneServer(); + ->useCache('database'); +``` + ### Background Tasks From c334ea608531f7298ecea83c76f386ba9ff07208 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Sat, 22 Mar 2025 11:53:11 -0500 Subject: [PATCH 2/2] formatting --- scheduling.md | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/scheduling.md b/scheduling.md index 5299ce13863..d938d24cd04 100644 --- a/scheduling.md +++ b/scheduling.md @@ -362,6 +362,15 @@ Schedule::command('report:generate') ->onOneServer(); ``` +You may use the `useCache` method to customize the cache store used by the scheduler to obtain the atomic locks necessary for single-server tasks: + +```php +Schedule::command('recipes:sync') + ->everyThirtyMinutes() + ->onOneServer(); + ->useCache('database'); +``` + #### Naming Single Server Jobs @@ -388,17 +397,6 @@ Schedule::call(fn () => User::resetApiRequestCount()) ->onOneServer(); ``` - -#### Customizing the Cache Driver -If you need to override the default cache driver used for scheduling's atomic mutex locks, you can chain the `useCache` method after `onOneServer`. This allows you to specify a different cache driver (e.g. `'database'`) for the mutex without changing your application's primary cache configuration: - -```php -Schedule::command('recipes:sync') - ->everyThirtyMinutes() - ->onOneServer(); - ->useCache('database'); -``` - ### Background Tasks