Yoast\WP\SEO\Helpers

Lock_Helper::executepublicYoast 1.0

Acquires a lock, executes the callback, and releases the lock.

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

Хуков нет.

Возвращает

T. The callback's return value.

Использование

$Lock_Helper = new Lock_Helper();
$Lock_Helper->execute( $lock_key, $callback, $ttl_in_seconds, $max_attempts, $retry_delay_microseconds );
$lock_key(строка) (обязательный)
The lock key.
$callback(callable) (обязательный)
.
$ttl_in_seconds(int)
The lock TTL in seconds.
По умолчанию: 30
$max_attempts(int)
The maximum number of acquisition attempts.
По умолчанию: 5
$retry_delay_microseconds(int)
The delay between attempts in microseconds.
По умолчанию: 20000 (20ms)

Код Lock_Helper::execute() Yoast 28.3

public function execute( string $lock_key, callable $callback, int $ttl_in_seconds = 30, int $max_attempts = 5, int $retry_delay_microseconds = 20_000 ) {
	$this->acquire( $lock_key, $ttl_in_seconds, $max_attempts, $retry_delay_microseconds );

	try {
		return $callback();
	}
	finally {
		$this->store->delete_for_multisite( $lock_key );
	}
}