Yoast\WP\SEO\Expiring_Store\Application
Expiring_Store::do_persist_if_absent
Persists a value only if the prefixed key does not already exist.
Метод класса: Expiring_Store{}
Хуков нет.
Возвращает
true|false. True if the value was inserted, false if the key already exists.
Использование
// private - только в коде основоного (родительского) класса $result = $this->do_persist_if_absent( $prefixed_key, $value, $ttl_in_seconds ): bool;
- $prefixed_key(строка) (обязательный)
- The prefixed key.
- $value(строка|int|float|true|false|array<string|int|float|true|false|массив|null>|JsonSerializable) (обязательный)
- The value to store.
- $ttl_in_seconds(int) (обязательный)
- The time-to-live in seconds.
Код Expiring_Store::do_persist_if_absent() Expiring Store::do persist if absent Yoast 27.7
private function do_persist_if_absent( string $prefixed_key, $value, int $ttl_in_seconds ): bool {
$json = $this->json_encode_value( $value );
$now = $this->date_helper->current_time();
$exp = \gmdate( 'Y-m-d H:i:s', ( $now + $ttl_in_seconds ) );
return $this->repository->insert_if_absent( $prefixed_key, $json, $exp, \gmdate( 'Y-m-d H:i:s', $now ) );
}