PHP.mk документација

Yac::dump

Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.

yac.dump.php PHP.net прокси Преводот се освежува
Оригинал на PHP.net
Патека yac.dump.php Локална патека за оваа страница.
Извор php.net/manual/en Оригиналниот HTML се реупотребува и локално се стилизира.
Режим Прокси + превод во позадина Кодовите, табелите и белешките остануваат читливи во истиот тек.
Yac::dump

Референца за `yac.dump.php` со подобрена типографија и навигација.

yac.dump.php

Yac::dump

(PECL yac >= 1.0.0)

Yac::dumpDump cache entries for inspection

= NULL

public function Yac::dump(int $limit = 100, int $offset = 0): array

Dumps metadata of the entries currently stored in the cache. The values themselves are not returned.

Параметри

limit

Maximum number of entries to return.

offset

Number of entries to skip before collecting, which can be used to page through a cache that holds more entries than limit.

Вратени вредности

Еден array with one element per dumped entry. Each element is itself an array describing the entry:

index

The slot index of the entry in the hash table.

hash

The 64-bit hash of the key, used for slot probing.

crc

The CRC32 checksum of the stored value, used to detect torn reads. 0 for embedded entries, which have no value block.

ttl

The expiration timestamp (Unix time). 0 means the entry never expires by time. Note that Yac::delete() only marks an entry expired, so deleted entries can still show up in the dump; a non-zero ttl in the past indicates an expired or deleted entry.

k_len

The length of the key, in bytes.

v_len

The length of the value, in bytes. For compressed entries this is the length of the original value before compression (as of yac 2.4.0; earlier versions reported the stored, compressed length).

c_len

Only present for compressed entries (as of yac 2.4.0): the length of the compressed payload actually stored in shared memory, in bytes. Comparing c_len with v_len shows how much compression saves per entry.

size

The allocated size of the value block in shared memory, in bytes. 0 for embedded entries.

atime

The last access time (Unix time), updated on each successful Yac::get(). When the cache is full, the entry with the oldest atime among the candidate slots is evicted first (as of yac 2.4.0).

hits

A per-entry hit counter, bumped on each successful Yac::get(), reset when the entry is overwritten, deleted or expires (as of yac 2.4.0).

embedded

Whether the value is stored directly inside the slot instead of in a separate value block (as of yac 2.4.0). Small values — NULL, booleans, small integers, strings of up to 7 bytes and empty arrays — are embedded this way and allocate no value memory at all; for them crc and size are reported as 0.

key

The cache key, without any instance prefix.

Примери

Пример #1 Yac::dump() example

<?php
$yac = new Yac();
$yac->set("foo", "bar");
$yac->set("baz", "qux");

print_r($yac->dump());
?>

Горниот пример ќе прикаже нешто слично на:

Array
(
    [0] => Array
        (
            [index] => 12345
            [hash] => 14463105906481965911
            [crc] => 0
            [ttl] => 0
            [k_len] => 3
            [v_len] => 3
            [size] => 0
            [atime] => 1725955200
            [hits] => 0
            [embedded] => 1
            [key] => foo
        )

    [1] => Array
        (
            [index] => 12987
            [hash] => 15132029420525657053
            [crc] => 0
            [ttl] => 0
            [k_len] => 3
            [v_len] => 3
            [size] => 0
            [atime] => 1725955200
            [hits] => 0
            [embedded] => 1
            [key] => baz
        )

)

Entries are listed in slot order, not in the order they were stored. Embedded entries (short scalars kept inside the slot itself) have crc and size set to zero; entries stored in a separate value block carry their checksum and block size, and compressed entries additionally carry c_len.

Example #2 Paging through a large cache

limit bounds how many entries a single call returns, and offset skips that many entries before collecting, so the two can be combined to page through a cache that holds more entries than one call may return.

<?php
$yac = new Yac();

$page_size = 100;
$page_num  = 2;

// skip the first 100 entries and return the next 100 (page 2)
$page = $yac->dump($page_size, $page_size * ($page_num - 1));

var_dump(count($page));
?>

Горниот пример ќе прикаже нешто слично на:

int(100)

Fewer entries than requested are returned when the cache holds fewer entries than the requested page covers, and an empty array is returned once the offset points past the last occupied slot.

Види Исто така

  • Yac::info() - Преземи вредности од кешот

Белешки од корисници

Нема белешки од корисници за оваа страница.
Навигација

Прелистувај сродни теми и функции.

На оваа страница

Автоматски outline од активната документација.

Насловите ќе се појават тука по вчитување.

Попрегледно читање

Примерите, changelog табелите и user notes се визуелно издвоени за да не се губат во долгата содржина.

Брз совет Користи го outline-от Скокни директно на главните секции од активната страница.
Извор Оригиналниот линк останува достапен Кога ти треба целосен upstream context, отвори го PHP.net во нов tab.