Blogger Information
Blog 6
fans 0
comment 0
visits 4001
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
memcached3
JIE的博客
Original
743 people have browsed it

PHP如何使用

-----------------------------------------------------

注意:在使用Memcache前需要开启php的支持

         1. 将php_memcache.dll模块文件复制到php的ext/目录下

         2. 在php.ini中设置支持php_memcache.dll

         extension=php_memcache.dll

         3. 重启Apache服务

         测试访问phpinfo()

        

             $mm=new Memcache(); //创建对象

            

             $mm->addServer("127.0.0.1", 11211);//连接服务器

            

             $mm->add(string $key , mixed $var [, int $flag [, int $expire ]]); //添加数据

             其中:

             $mem->add("var_1", "this is a test", MEMCACHE_COMPRESSED, 10000);


             $mem->add("var_2", array("aaa", "bbb", "ccc"), MEMCACHE_COMPRESSED, 10000);

            

             class Person{

             var $name="zhangsan";

             var $age=10;

             }

            

             $mem->add("var_3", new Person(), MEMCACHE_COMPRESSED, 10000);


          

             print_r($mem->get("var_1"));

             echo '<br>';

            

             var_dump($mem->get("var_2"));

             echo '<br>';

             var_dump($mem->get("var_3"));

             echo '<br>';

             $mem->close();

            

            

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post