ActionScheduler_OptionLock::get_existing_lock
Supplies the existing lock value, or null if not set.
Метод класса: ActionScheduler_OptionLock{}
Хуков нет.
Возвращает
string|null.
Использование
// private - только в коде основоного (родительского) класса $result = $this->get_existing_lock( $lock_type, $now );
- $lock_type(строка) (обязательный)
- A string to identify different lock types.
- $now(int) (обязательный)
- The timestamp to use.
Код ActionScheduler_OptionLock::get_existing_lock() ActionScheduler OptionLock::get existing lock WC 11.2.2
private function get_existing_lock( $lock_type, int $now ) {
global $wpdb;
$lock_key = $this->get_key( $lock_type );
$cached = wp_cache_get( $lock_key, 'action_scheduler_locks' );
if ( false !== $cached ) {
return (string) $cached;
}
$value = null;
// Now grab the existing lock value, if there is one.
// get_var() returns null for the empty string ('') so we must use get_row().
$row = $wpdb->get_row(
$wpdb->prepare(
"SELECT option_value FROM $wpdb->options WHERE option_name = %s",
$lock_key
)
);
if ( $row ) {
$value = $row->option_value;
// Sync cache as necessary.
$ttl = $this->get_expiration_from( $value ) - $now;
if ( $ttl > 0 ) {
wp_cache_set( $lock_key, $value, 'action_scheduler_locks', $ttl );
}
}
return $value;
}