<?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry id="function.Memcache-add"> <refnamediv> <refname>Memcache::add</refname> <refpurpose>Add an item to the server</refpurpose> </refnamediv> <refsect1> <title>Description</title> <methodsynopsis> <type>bool</type><methodname>Memcache::add</methodname> <methodparam><type>string</type><parameter>key</parameter></methodparam> <methodparam><type>mixed</type><parameter>var</parameter></methodparam> <methodparam choice="opt"><type>int</type><parameter>flag</parameter></methodparam> <methodparam choice="opt"><type>int</type><parameter>expire</parameter></methodparam> </methodsynopsis> <para> <function>Memcache::add</function> stores variable <parameter>var</parameter> with <parameter>key</parameter> only if such key doesn't exist at the server yet. <function>Memcache::add</function> returns &false; if such key already exist. For the rest <function>Memcache::add</function> behaves similarly to <function>Memcache::set</function>. </para> <para> Also you can use <function>memcache_add</function> function. See example below. </para> <example> <title><function>Memcache::add</function> example</title> <programlisting role="php"> <![CDATA[ <?php $memcache_obj = memcache_connect("localhost", 11211); /* procedural API */ memcache_add($memcache_obj, 'var_key', 'test variable', false, 30); /* OO API */ $memcache_obj->add('var_key', 'test variable', false, 30); ?> ]]> </programlisting> </example> <para> <function>Memcache::add</function> returns &true; on success or &false; on failure. </para> <para> See also <function>Memcache::set</function>, <function>Memcache::replace</function>. </para> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->