Automattic\WooCommerce\Internal\Api
QueryCache::read_from_opcache
Read a cached DocumentNode from the OPcache file backend.
Метод класса: QueryCache{}
Хуков нет.
Возвращает
DocumentNode|false.
Использование
// private - только в коде основоного (родительского) класса $result = $this->read_from_opcache( $hash );
- $hash(строка) (обязательный)
- The SHA-256 hash.
Код QueryCache::read_from_opcache() QueryCache::read from opcache WC 11.0.1
private function read_from_opcache( string $hash ) {
$path = self::get_opcache_cache_dir() . '/' . $hash . '.php';
if ( ! is_file( $path ) ) {
return false;
}
// File contents are produced by self::write_to_opcache() and only
// ever return a primitive array. The caller falls back to parsing
// when the include returns a non-array.
$data = include $path;
if ( ! is_array( $data ) ) {
return false;
}
try {
return AST::fromArray( $data );
} catch ( \Throwable $e ) {
return false;
} finally {
OpcacheFileExpiry::ensure_scheduled();
}
}