Yoast\WP\SEO\Helpers
Lock_Helper::acquire
Attempts to acquire the lock with retries.
Метод класса: Lock_Helper{}
Хуков нет.
Возвращает
void. Ничего (null).
Использование
// private - только в коде основоного (родительского) класса $result = $this->acquire( $lock_key, $ttl_in_seconds, $max_attempts, $retry_delay_microseconds ): void;
- $lock_key(строка) (обязательный)
- The lock key.
- $ttl_in_seconds(int) (обязательный)
- The lock TTL in seconds.
- $max_attempts(int) (обязательный)
- The maximum number of attempts.
- $retry_delay_microseconds(int) (обязательный)
- The delay between attempts in microseconds.
Код Lock_Helper::acquire() Lock Helper::acquire Yoast 28.9
private function acquire( string $lock_key, int $ttl_in_seconds, int $max_attempts, int $retry_delay_microseconds ): void {
for ( $attempt = 1; $attempt <= $max_attempts; $attempt++ ) {
if ( $this->store->persist_if_absent_for_multisite( $lock_key, true, $ttl_in_seconds ) ) {
return;
}
if ( $attempt < $max_attempts ) {
\usleep( $retry_delay_microseconds );
}
}
// phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- This is an exception message, not output.
throw new Lock_Timeout_Exception( $lock_key, $max_attempts );
}