<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Delete an item</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="memcached.decrementbykey.html">Memcached::decrementByKey</a></div> <div class="next" style="text-align: right; float: right;"><a href="memcached.deletebykey.html">Memcached::deleteByKey</a></div> <div class="up"><a href="class.memcached.html">Memcached</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="memcached.delete" class="refentry"> <div class="refnamediv"> <h1 class="refname">Memcached::delete</h1> <p class="verinfo">(PECL memcached >= 0.1.0)</p><p class="refpurpose"><span class="refname">Memcached::delete</span> — <span class="dc-title">Delete an item</span></p> </div> <div class="refsect1 description" id="refsect1-memcached.delete-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">bool</span> <span class="methodname"><strong>Memcached::delete</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$key</code></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$time</code><span class="initializer"> = 0</span></span> ] )</div> <p class="para rdfs-comment"> <span class="function"><strong>Memcached::delete()</strong></span> deletes the <em><code class="parameter">key</code></em> from the server. The <em><code class="parameter">time</code></em> parameter is the amount of time in seconds (or Unix time until which) the client wishes the server to refuse <em>add</em> and <em>replace</em> commands for this key. For this amount of time, the item is put into a delete queue, which means that it won't possible to retrieve it by the <em>get</em> command, but <em>add</em> and <em>replace</em> command with this key will also fail (the <em>set</em> command will succeed, however). After the time passes, the item is finally deleted from server memory. The parameter <em><code class="parameter">time</code></em> defaults to 0 (which means that the item will be deleted immediately and further storage commands with this key will succeed). </p> </div> <div class="refsect1 parameters" id="refsect1-memcached.delete-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">key</code></em></span> <dd> <p class="para"> The key to be deleted. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">time</code></em></span> <dd> <p class="para"> The amount of time the server will wait to delete the item. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-memcached.delete-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns <strong><code>TRUE</code></strong> on success or <strong><code>FALSE</code></strong> on failure. The <span class="methodname"><a href="memcached.getresultcode.html" class="methodname">Memcached::getResultCode()</a></span> will return <strong><code>Memcached::RES_NOTFOUND</code></strong> if the key does not exist. </p> </div> <div class="refsect1 examples" id="refsect1-memcached.delete-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-4434"> <p><strong>Example #1 <span class="function"><strong>Memcached::delete()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br />$m </span><span style="color: #007700">= new </span><span style="color: #0000BB">Memcached</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$m</span><span style="color: #007700">-></span><span style="color: #0000BB">addServer</span><span style="color: #007700">(</span><span style="color: #DD0000">'localhost'</span><span style="color: #007700">, </span><span style="color: #0000BB">11211</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$m</span><span style="color: #007700">-></span><span style="color: #0000BB">delete</span><span style="color: #007700">(</span><span style="color: #DD0000">'key1'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> </div> <div class="refsect1 seealso" id="refsect1-memcached.delete-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="methodname"><a href="memcached.deletebykey.html" class="methodname" rel="rdfs-seeAlso">Memcached::deleteByKey()</a> - Delete an item from a specific server</span></li> <li class="member"> <span class="methodname"><a href="memcached.deletemulti.html" class="methodname" rel="rdfs-seeAlso">Memcached::deleteMulti()</a> - Delete multiple items</span></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="memcached.decrementbykey.html">Memcached::decrementByKey</a></div> <div class="next" style="text-align: right; float: right;"><a href="memcached.deletebykey.html">Memcached::deleteByKey</a></div> <div class="up"><a href="class.memcached.html">Memcached</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>