1
0
mirror of https://github.com/php/doc-es.git synced 2026-03-28 17:32:16 +01:00
Files
archived-doc-es/reference/memcache/examples.xml
Yago Ferrer 70ba0adc12 Adding Memcache.
git-svn-id: https://svn.php.net/repository/phpdoc/es/trunk@294202 c90b9560-bf6c-de11-be94-00142212c4b1
2010-01-29 13:18:05 +00:00

85 lines
2.2 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 288721 $ -->
<!-- EN-Revision: af4410a7e15898c3dbe83d6ea38246745ed9c6fb Maintainer: yago Status: ready -->
<chapter xml:id="memcache.examples" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
&reftitle.examples;
<section xml:id="memcache.examples-overview">
<para>
<example>
<title>Ejemplos de la extensión memcache extension</title>
<para>
En este ejemplo, se guarda un objecto en cache y luego se devuelve de nuevo.
Objetos y otros tipos no escalares se serializan antes de guardarse, por lo
tanto es imposible guardar recursos. (ej. identificadores de conexión y otros
tipos) en caché.
</para>
<programlisting role="php">
<![CDATA[
<?php
$memcache = new Memcache;
$memcache->connect('localhost', 11211) or die ("No se pudo contectar");
$version = $memcache->getVersion();
echo "Versión del servidor: ".$version."<br/>\n";
$tmp_object = new stdClass;
$tmp_object->str_attr = 'test';
$tmp_object->int_attr = 123;
$memcache->set('key', $tmp_object, false, 10) or die ("Falló al intentar guardar datos el en servidor");
echo "Guarda datos en caché (los datos expirarán en 10 segundos)<br/>\n";
$get_result = $memcache->get('key');
echo "Datos desde la caché:<br/>\n";
var_dump($get_result);
?>
]]>
</programlisting>
</example>
</para>
<para>
<example>
<title>Usando el gestor de sesiones de memcache</title>
<programlisting role="php">
<![CDATA[
<?php
$session_save_path = "tcp://$host:$port?persistent=1&weight=2&timeout=2&retry_interval=10, ,tcp://$host:$port ";
ini_set('session.save_handler', 'memcache');
ini_set('session.save_path', $session_save_path);
?>
]]>
</programlisting>
</example>
</para>
</section>
</chapter>
<!-- 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:"~/.phpdoc/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
-->