ActionScheduler_OptionLock::set()publicWC 1.0

Set a lock using options for a given amount of time (60 seconds by default).

Using an autoloaded option avoids running database queries or other resource intensive tasks on frequently triggered hooks, like 'init' or 'shutdown'.

For example, ActionScheduler_QueueRunner->maybe_dispatch_async_request() uses a lock to avoid calling ActionScheduler_QueueRunner->has_maximum_concurrent_batches() every time the 'shutdown', hook is triggered, because that method calls ActionScheduler_QueueRunner->store->get_claim_count() to find the current number of claims in the database.

Метод класса: ActionScheduler_OptionLock{}

Хуков нет.


null. Ничего.


$ActionScheduler_OptionLock = new ActionScheduler_OptionLock();
$ActionScheduler_OptionLock->set( $lock_type );
$lock_type(строка) (обязательный)
A string to identify different lock types.

Код ActionScheduler_OptionLock::set() WC 7.7.0

public function set( $lock_type ) {
	return update_option( $this->get_key( $lock_type ), time() + $this->get_duration( $lock_type ) );