›
›
›
  1. docs
  2. ›
  3. byrcsc/laravel-hold
1.x
Browse documentationOpenClose

Getting started

  • Introduction
  • Installation and setup
  • Quick start

Core concepts

  • Holdables and holders
  • Capacity and slots
  • Acquiring holds
  • Releasing and extending
  • Expiry
  • Hold state

Operations

  • Events and listeners
  • Scheduling expiry
  • Pruning history
  • Concurrency and databases

Reference

  • Configuration
  • Console commands
  • Database schema
  • Testing
  • Troubleshooting

Getting started

  • Introduction
  • Installation and setup
  • Quick start

Core concepts

  • Holdables and holders
  • Capacity and slots
  • Acquiring holds
  • Releasing and extending
  • Expiry
  • Hold state

Operations

  • Events and listeners
  • Scheduling expiry
  • Pruning history
  • Concurrency and databases

Reference

  • Configuration
  • Console commands
  • Database schema
  • Testing
  • Troubleshooting

byrcsc/laravel-hold · 1.x

Console commands.

Announce expired holds and prune old history through Artisan.

CommandWhat it does
hold:expireStamp passed expiries and fire HoldExpired
hold:prune [--days=]Delete holds that died before the cutoff

Both are optional. Availability is correct with neither ever running: hold:expire only announces what the clock has already done, and hold:prune only bounds history. The package registers no schedule for either.

hold:expire

php artisan hold:expire

No arguments and no options.

Expired 3 holds.

Stamps expired_at on every hold that is unreleased, unstamped, and past its expiry, and fires one HoldExpired event for each. The count is of holds this run claimed, so a second run over the same table reports Expired 0 holds.

Always exits zero, including when there is nothing to stamp.

Walks the table in chunks of 500 by primary key, reading the clock once for the whole run. Overlapping runs are safe: the stamp is a conditional update, so exactly one run announces each hold.

Details in scheduling expiry.

hold:prune

php artisan hold:prune
php artisan hold:prune --days=90
php artisan hold:prune --days=0
OptionEffect
--days=Days of dead holds to keep. Defaults to 30
Pruned 412 holds.

Deletes holds released, or expired, more than --days days ago. Active and indefinite holds are never deleted, whatever the window. Fires no events.

Exits zero on success. Exits non-zero, deleting nothing, when --days is not a whole number of days at least zero:

The --days option must be a whole number of days, zero or more.

That covers negative numbers, decimals, and non-numeric strings. A negative window would put the cutoff in the future, where live holds are.

Deletes in passes of 500 keys until a pass removes nothing.

Details in pruning history.

Scheduling both

use Illuminate\Support\Facades\Schedule;

Schedule::command('hold:expire')->everyMinute();
Schedule::command('hold:prune --days=90')->dailyAt('03:00');

Schedule hold:expire only if something listens for HoldExpired. Choose the hold:prune window from your retention policy.

Publishing commands

The package also ships two publish tags, used once at install time:

php artisan vendor:publish --tag="hold-config"
php artisan vendor:publish --tag="hold-migrations"

hold-config writes config/hold.php. hold-migrations writes the create_holds_table migration into your application, timestamped at publish time. See installation and setup.

What to read next

  • Scheduling expiry for what hold:expire guarantees and what it does not.
  • Pruning history for choosing a retention window.
  • Configuration for the settings neither command exposes.
PreviousConfigurationNextDatabase schema
View source

On this page

  1. hold:expire
  2. hold:prune
  3. Scheduling both
  4. Publishing commands
  5. What to read next