<?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 => 'en',
  ),
  'this' => 
  array (
    0 => 'yac.delete.php',
    1 => 'Yac::delete',
    2 => 'Remove items from cache',
  ),
  'up' => 
  array (
    0 => 'class.yac.php',
    1 => 'Yac',
  ),
  'prev' => 
  array (
    0 => 'yac.construct.php',
    1 => 'Yac::__construct',
  ),
  'next' => 
  array (
    0 => 'yac.dump.php',
    1 => 'Yac::dump',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/yac/yac/delete.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="yac.delete" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Yac::delete</h1>
  <p class="verinfo">(PECL yac &gt;= 1.0.0)</p><p class="refpurpose"><span class="refname">Yac::delete</span> &mdash; <span class="dc-title">Remove items from cache</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-yac.delete-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="modifier">function</span> <span class="methodname"><strong>Yac::delete</strong></span>(<span class="methodparam"><span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.array.php" class="type array">array</a></span></span> <code class="parameter">$key</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$delay</code><span class="initializer"> = 0</span></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="simpara">
   Removes one or more items from the cache.
  </p>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="simpara">
    Deletion is implemented by marking the entry expired rather than
    clearing its slot: the entry immediately stops being readable, but
    the slot stays occupied until the same key is stored again or a
    later write reclaims the slot. As a result, the used-slot count
    reported by <span class="methodname"><a href="yac.info.php" class="methodname">Yac::info()</a></span> does not decrease
    after a deletion, and <span class="methodname"><a href="yac.dump.php" class="methodname">Yac::dump()</a></span> still
    lists the deleted entry until its slot is recycled; a non-zero
    <code class="literal">ttl</code> in the past marks a deleted or expired
    entry, so when inspecting the output of
    <span class="methodname"><a href="yac.dump.php" class="methodname">Yac::dump()</a></span>, such entries have to be
    filtered out by the caller.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 parameters" id="refsect1-yac.delete-parameters">
  <h3 class="title">Parameters</h3>
  <dl>
   
    <dt><code class="parameter">key</code></dt>
    <dd>
     <p class="simpara">
      A <span class="type"><a href="language.types.string.php" class="type string">string</a></span> key, or an <span class="type"><a href="language.types.array.php" class="type array">array</a></span> of keys to be
      removed.
     </p>
    </dd>
   
   
    <dt><code class="parameter">delay</code></dt>
    <dd>
     <p class="simpara">
      Number of seconds before the item becomes invalid. When omitted or
      <code class="literal">0</code>, the item is invalidated immediately. A positive
      value keeps the item readable for that many seconds before it
      expires.
     </p>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-yac.delete-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="simpara">
   Returns <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> on success, or <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> if the key was not present in
   the cache. Because a deletion only marks the entry expired, a key
   that was deleted but not yet overwritten still counts as present:
   deleting the same key again returns <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>.
  </p>
  <p class="simpara">
   When an <span class="type"><a href="language.types.array.php" class="type array">array</a></span> of keys is given, <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> is returned
   only if every key was present; if any key is missing, <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> is
   returned.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-yac.delete-examples">
  <h3 class="title">Examples</h3>
  <div class="example" id="example-1">
   <p><strong>Example #1 <span class="methodname"><strong>Yac::delete()</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">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$yac</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">delete</span><span style="color: #007700">(</span><span style="color: #DD0000">"foo"</span><span style="color: #007700">));      </span><span style="color: #FF8000">// bool(true): marked expired
</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$yac</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">get</span><span style="color: #007700">(</span><span style="color: #DD0000">"foo"</span><span style="color: #007700">));         </span><span style="color: #FF8000">// bool(false): a miss from now on
</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$yac</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">delete</span><span style="color: #007700">(</span><span style="color: #DD0000">"foo"</span><span style="color: #007700">));      </span><span style="color: #FF8000">// bool(true) again: the slot has not
                                     // been overwritten yet
</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$yac</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">delete</span><span style="color: #007700">(</span><span style="color: #DD0000">"never"</span><span style="color: #007700">));    </span><span style="color: #FF8000">// bool(false): was never stored

// a deletion does not free the slot: slots_used does not drop, and
// the expired entry still shows up in the dump
</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$yac</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">info</span><span style="color: #007700">()[</span><span style="color: #DD0000">"slots_used"</span><span style="color: #007700">]); </span><span style="color: #FF8000">// int(1)
</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: #FF8000">// "foo" is still listed; its ttl
                                       // is in the past
</span><span style="color: #0000BB">?&gt;</span></code></pre></div>
   </div>

  </div>
  <div class="example" id="example-2">
   <p><strong>Example #2 Delayed deletion</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: #FF8000">// keep the entry readable for 60 more seconds before it expires
</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">"tmp"</span><span style="color: #007700">, </span><span style="color: #DD0000">"value"</span><span style="color: #007700">);
</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$yac</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">delete</span><span style="color: #007700">(</span><span style="color: #DD0000">"tmp"</span><span style="color: #007700">, </span><span style="color: #0000BB">60</span><span style="color: #007700">));    </span><span style="color: #FF8000">// bool(true)
</span><span style="color: #0000BB">?&gt;</span></code></pre></div>
   </div>

  </div>
  <div class="example" id="example-3">
   <p><strong>Example #3 Deleting multiple keys at once</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">"tmp"</span><span style="color: #007700">, </span><span style="color: #DD0000">"value"</span><span style="color: #007700">);

</span><span style="color: #FF8000">// returns true only when every key was present
</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$yac</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">delete</span><span style="color: #007700">(array(</span><span style="color: #DD0000">"tmp"</span><span style="color: #007700">, </span><span style="color: #DD0000">"nope"</span><span style="color: #007700">))); </span><span style="color: #FF8000">// bool(false): "nope" missing
</span><span style="color: #0000BB">?&gt;</span></code></pre></div>
   </div>

  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-yac.delete-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="methodname"><a href="yac.set.php" class="methodname" rel="rdfs-seeAlso">Yac::set()</a> - Store a value into the cache</span></li>
    <li><span class="methodname"><a href="yac.flush.php" class="methodname" rel="rdfs-seeAlso">Yac::flush()</a> - Flush the cache</span></li>
    <li><span class="methodname"><a href="yac.info.php" class="methodname" rel="rdfs-seeAlso">Yac::info()</a> - Status of cache</span></li>
    <li><span class="methodname"><a href="yac.dump.php" class="methodname" rel="rdfs-seeAlso">Yac::dump()</a> - Dump cache entries for inspection</span></li>
   </ul>
  </p>
 </div>


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