Home > php教程 > php手册 > body text

PHP 使用memcached简单示例分享

PHPz
Release: 2018-09-28 11:51:52
Original
855 people have browsed it

在很多场合,我们都会听到 memcached 这个名字,但很多同学只是听过,并没有用过或实际了解过,只知道它是一个很不错的东东。

1.添加扩展包

 代码如下:

php_memcache.dll
Copy after login

2.在PHP.INI添加

代码如下:

extension=php_memcache.dll
Copy after login

3.程序

代码如下:

<?php
    //创建一个mem对象实例
    $mem=new Memcache;
    if(!$mem->connect("10.18.110.213",11211)){
        die(&#39;连接失败!&#39;);
    }
    //增加
    //1.增加一个字串
/*    if($mem->set(&#39;key1&#39;,"beijing",MEMCACHE_COMPRESSED,60)){
        echo &#39;添加ok&#39;;
    }*/
    //2.添加数值
/*    if($mem->set(&#39;key1&#39;,100,MEMCACHE_COMPRESSED,60)){
        echo &#39;添加ok&#39;;
    }*/
    //3.添加数组
    //在添加数组是,根据需要. 希望序列号放入  ,
    //serialize
Copy after login

以上就是本文关于php中使用memcache的用法介绍,希望对大家能够有所帮助。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!