<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.yac.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'yac.dump.php',
    1 => 'Yac::dump',
    2 => 'Dump cache entries for inspection',
  ),
  'up' => 
  array (
    0 => 'class.yac.php',
    1 => 'Yac',
  ),
  'prev' => 
  array (
    0 => 'yac.delete.php',
    1 => 'Yac::delete',
  ),
  'next' => 
  array (
    0 => 'yac.flush.php',
    1 => 'Yac::flush',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/yac/yac/dump.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="yac.dump" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Yac::dump</h1>
  <p class="verinfo">(PECL yac &gt;= 1.0.0)</p><p class="refpurpose"><span class="refname">Yac::dump</span> &mdash; <span class="dc-title">Dump cache entries for inspection</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-yac.dump-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="modifier">function</span> <span class="methodname"><strong>Yac::dump</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$limit</code><span class="initializer"> = 100</span></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$offset</code><span class="initializer"> = 0</span></span>): <span class="type"><a href="language.types.array.php" class="type array">array</a></span></div>

  <p class="simpara">
   Dumps metadata of the entries currently stored in the cache. The
   values themselves are not returned.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-yac.dump-parameters">
  <h3 class="title">Параметри</h3>
  <dl>
   
    <dt><code class="parameter">limit</code></dt>
    <dd>
     <p class="simpara">
      Maximum number of entries to return.
     </p>
     <p class="simpara">
      Passing <code class="literal">-1</code> as <code class="parameter">limit</code> dumps
      every entry the cache currently holds. Note that building the
      full list may use a considerable amount of memory for a large
      cache; when memory matters, page through the entries with
      <code class="parameter">limit</code> and <code class="parameter">offset</code> instead.
     </p>
    </dd>
   
   
    <dt><code class="parameter">offset</code></dt>
    <dd>
     <p class="simpara">
      Number of entries to skip before collecting. This parameter
      is available as of PECL yac 2.4.0; earlier versions always
      start from the first entry. Combined with
      <code class="parameter">limit</code>, it can be used to page through a
      cache that holds more entries than one call may return.
     </p>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-yac.dump-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="simpara">
   An <span class="type"><a href="language.types.array.php" class="type array">array</a></span> with one element per dumped entry. Each element
   is itself an array describing the entry:
  </p>
  <dl>
   
    <dt><code class="literal">index</code></dt>
    <dd><p class="simpara">
     The slot index of the entry in the hash table.
    </p></dd>
   
   
    <dt><code class="literal">hash</code></dt>
    <dd><p class="simpara">
     The 64-bit hash of the key, used for slot probing.
    </p></dd>
   
   
    <dt><code class="literal">crc</code></dt>
    <dd><p class="simpara">
     The CRC32 checksum of the stored value, used to detect torn reads.
     <code class="literal">0</code> for embedded entries, which have no value block.
    </p></dd>
   
   
    <dt><code class="literal">ttl</code></dt>
    <dd><p class="simpara">
     The expiration timestamp (Unix time). <code class="literal">0</code> means the
     entry never expires by time. Note that
     <span class="methodname"><a href="yac.delete.php" class="methodname">Yac::delete()</a></span> only marks an entry expired, so
     deleted entries can still show up in the dump; a non-zero
     <code class="literal">ttl</code> in the past indicates an expired or deleted
     entry.
    </p></dd>
   
   
    <dt><code class="literal">k_len</code></dt>
    <dd><p class="simpara">
     The length of the key, in bytes.
    </p></dd>
   
   
    <dt><code class="literal">v_len</code></dt>
    <dd><p class="simpara">
     The length of the value, in bytes. For compressed entries this is the
     length of the <em>original</em> value before compression
     (as of yac 2.4.0; earlier versions reported the stored, compressed
     length).
    </p></dd>
   
   
    <dt><code class="literal">c_len</code></dt>
    <dd><p class="simpara">
     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 <code class="literal">c_len</code> with <code class="literal">v_len</code> shows
     how much compression saves per entry.
    </p></dd>
   
   
    <dt><code class="literal">size</code></dt>
    <dd><p class="simpara">
     The allocated size of the value block in shared memory, in bytes.
     <code class="literal">0</code> for embedded entries.
    </p></dd>
   
   
    <dt><code class="literal">atime</code></dt>
    <dd><p class="simpara">
     The last access time (Unix time), updated on each successful
     <span class="methodname"><a href="yac.get.php" class="methodname">Yac::get()</a></span>. When the cache is full, the entry
     with the oldest <code class="literal">atime</code> among the candidate slots is
     evicted first (as of yac 2.4.0).
    </p></dd>
   
   
    <dt><code class="literal">hits</code></dt>
    <dd><p class="simpara">
     A per-entry hit counter, bumped on each successful
     <span class="methodname"><a href="yac.get.php" class="methodname">Yac::get()</a></span> and reset when the entry is
     overwritten by a new <span class="methodname"><a href="yac.set.php" class="methodname">Yac::set()</a></span> or
     <span class="methodname"><a href="yac.add.php" class="methodname">Yac::add()</a></span> (as of yac 2.4.0).
    </p></dd>
   
   
    <dt><code class="literal">embedded</code></dt>
    <dd><p class="simpara">
     Whether the value is stored directly inside the slot instead of in a
     separate value block (as of yac 2.4.0). Small values —
     <strong><code><a href="reserved.constants.php#constant.null">NULL</a></code></strong>, 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 <code class="literal">crc</code> and
     <code class="literal">size</code> are reported as <code class="literal">0</code>.
    </p></dd>
   
   
    <dt><code class="literal">key</code></dt>
    <dd><p class="simpara">
     The cache key, without any instance prefix.
    </p></dd>
   
  </dl>
 </div>


 <div class="refsect1 examples" id="refsect1-yac.dump-examples">
  <h3 class="title">Приклади</h3>
  <div class="example" id="example-1">
   <p><strong>Приклад #1 <span class="methodname"><strong>Yac::dump()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><pre><code style="color: #000000"><span style="color: #0000BB">&lt;?php
$yac </span><span style="color: #007700">= new </span><span style="color: #0000BB">Yac</span><span style="color: #007700">();
</span><span style="color: #0000BB">$yac</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">set</span><span style="color: #007700">(</span><span style="color: #DD0000">"foo"</span><span style="color: #007700">, </span><span style="color: #DD0000">"bar"</span><span style="color: #007700">);
</span><span style="color: #0000BB">$yac</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">set</span><span style="color: #007700">(</span><span style="color: #DD0000">"baz"</span><span style="color: #007700">, </span><span style="color: #DD0000">"qux"</span><span style="color: #007700">);

</span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$yac</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">dump</span><span style="color: #007700">());
</span><span style="color: #0000BB">?&gt;</span></code></pre></div>
   </div>

   <div class="example-contents"><p>Поданий вище приклад виведе щось
схоже на:</p></div>
   <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">Array
(
    [0] =&gt; Array
        (
            [index] =&gt; 12345
            [hash] =&gt; 14463105906481965911
            [crc] =&gt; 0
            [ttl] =&gt; 0
            [k_len] =&gt; 3
            [v_len] =&gt; 3
            [size] =&gt; 0
            [atime] =&gt; 1725955200
            [hits] =&gt; 0
            [embedded] =&gt; 1
            [key] =&gt; foo
        )

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

)</pre>
</div>
   </div>
   <div class="example-contents"><p>
    Entries are listed in slot order, not in the order they were stored.
    Embedded entries (short scalars kept inside the slot itself) have
    <code class="literal">crc</code> and <code class="literal">size</code> set to zero; entries
    stored in a separate value block carry their checksum and block size,
    and compressed entries additionally carry <code class="literal">c_len</code>.
   </p></div>
  </div>
  <div class="example" id="example-2">
   <p><strong>Приклад #2 Paging through a large cache</strong></p>
   <div class="example-contents"><p>
    <code class="parameter">limit</code> bounds how many entries a single call returns,
    and <code class="parameter">offset</code> 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.
   </p></div>
   <div class="example-contents">
<div class="phpcode"><pre><code style="color: #000000"><span style="color: #0000BB">&lt;?php
$yac </span><span style="color: #007700">= new </span><span style="color: #0000BB">Yac</span><span style="color: #007700">();

</span><span style="color: #FF8000">// fill the cache with 250 entries
</span><span style="color: #007700">for (</span><span style="color: #0000BB">$i </span><span style="color: #007700">= </span><span style="color: #0000BB">0</span><span style="color: #007700">; </span><span style="color: #0000BB">$i </span><span style="color: #007700">&lt; </span><span style="color: #0000BB">250</span><span style="color: #007700">; </span><span style="color: #0000BB">$i</span><span style="color: #007700">++) {
    </span><span style="color: #0000BB">$yac</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">set</span><span style="color: #007700">(</span><span style="color: #DD0000">"key</span><span style="color: #0000BB">$i</span><span style="color: #DD0000">"</span><span style="color: #007700">, </span><span style="color: #0000BB">$i</span><span style="color: #007700">);
}

</span><span style="color: #0000BB">$page_size </span><span style="color: #007700">= </span><span style="color: #0000BB">100</span><span style="color: #007700">;
</span><span style="color: #0000BB">$page_num  </span><span style="color: #007700">= </span><span style="color: #0000BB">2</span><span style="color: #007700">;

</span><span style="color: #FF8000">// skip the first 100 entries and return the next 100 (page 2)
</span><span style="color: #0000BB">$page </span><span style="color: #007700">= </span><span style="color: #0000BB">$yac</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$page_size</span><span style="color: #007700">, </span><span style="color: #0000BB">$page_size </span><span style="color: #007700">* (</span><span style="color: #0000BB">$page_num </span><span style="color: #007700">- </span><span style="color: #0000BB">1</span><span style="color: #007700">));

</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">count</span><span style="color: #007700">(</span><span style="color: #0000BB">$page</span><span style="color: #007700">));
</span><span style="color: #0000BB">?&gt;</span></code></pre></div>
   </div>

   <div class="example-contents"><p>Поданий вище приклад виведе щось
схоже на:</p></div>
   <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">int(100)</pre>
</div>
   </div>
   <div class="example-contents"><p>
    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.
   </p></div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-yac.dump-seealso">
  <h3 class="title">Прогляньте також</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="methodname"><a href="yac.info.php" class="methodname" rel="rdfs-seeAlso">Yac::info()</a> - Status of cache</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>