Home > Backend Development > PHP Tutorial > php的两个memcached扩展:memcache和memcached,开发中用哪个好

php的两个memcached扩展:memcache和memcached,开发中用哪个好

WBOY
Release: 2016-06-06 20:44:34
Original
910 people have browsed it

一直都用memcache类,居然发现还有memcached这个类
memcache扩展
memcached扩展

<code class="lang-php">$mem = new memcache();// $mem = new memcached();

</code>
Copy after login
Copy after login

回复内容:

一直都用memcache类,居然发现还有memcached这个类
memcache扩展
memcached扩展

<code class="lang-php">$mem = new memcache();// $mem = new memcached();

</code>
Copy after login
Copy after login

实际项目中会在php代码层面判断运行环境拥有哪个拓展就调用哪个
开发环境大多是WIN,就用memcache
生成环境大多Linux,就用memcached

<code>    if (extension_loaded('memcached')) {
        $this->cache = new \Memcached; 
    }else if(extension_loaded ('memcache'))
        $this->cache = new \Memcache;  
    else{
        $this->active = false;
        Log::error('Cache not support!');
        return false;
    }
</code>
Copy after login

cc: http://segmentfault.com/q/1010000000513661

Memcached 是一个受欢迎的选择,它能配合许多语言使用,包括 PHP。

然而,从一个 PHP 脚本中访问一个 Memcached 服务器,你有两个不同且命名很愚蠢的客户端库选择项:Memcache 和 Memcached。 它们是两个名字几乎相同的不同库,两者都可用于访问一个 Memcached 实例。

事实证明,Memcached 库对于 Memcached 协议的实现最好,包含了一些 Mmecache 库没有的有用的特性, 并且看起来 Memcached 库的开发也最为活跃。

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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template