php中memcache擴充及memcached擴充的區別

來源:互聯網
上載者:User

標籤:影響   pat   googl   memcached   .com   區別   php環境   不同   memcache   

1.目前大多數php環境裡使用的都是不帶d的memcache版本,這個版本出的比較早,是一個原生版本,完全在php架構內開發的。與之對應的帶d的memcached是建立在libmemcached的基礎上,所以相對來說,memcached版本的功能更全一些。

memcache:http://cn2.php.net/manual/en/book.memcache.php
memcached:http://cn2.php.net/manual/en/book.memcached.php
2.Memcache是原生實現的,支援OO和非OO兩套介面並存。而memcached是使用libmemcached,只支援OO介面。
3.memcached還有個非常稱讚的地方,就是flag不是在操作的時候設定了,而是有了一個統一的setOption()。Memcached實現了更多的memcached協議。
4.memcached支援Binary Protocol,而memcache不支援。這意味著memcached會有更高的效能。不過memcached目前還不支援長串連。

下面有一張表,來對比php用戶端擴充功能memcache與memcached
http://code.google.com/p/memcached/wiki/PHPClientComparison

另外一點也是大家比較關心的,就是所使用的演算法。大家都知道“一致性hash演算法”是當添加或刪除儲存節點時,對儲存在memcached上的資料影響較小的一種演算法。那麼在php的兩個擴充庫中,都可以使用該演算法,只是設定方法有所不同。
Memcache
修改php.ini添加:
[Memcache]
Memcache.allow_failover = 1
……
……
Memcache.hash_strategy =consistent
Memcache.hash_function =crc32
……
……
或在php中使用ini_set方法:
Ini_set(‘memcache.hash_strategy‘,‘standard‘);
Ini_set(‘memcache.hash_function‘,‘crc32‘);

Memcached
$mem = new memcached();
$mem->setOption(Memcached::OPT_DISTRIBUTION,Memcached::DISTRIBUTION_CONSISTENT);
$mem->setOption(Memcached::OPT_LIBKETAMA_COMPATIBLE,true);

 

轉載自:http://www.jb51.net/article/27366.htm

php中memcache擴充及memcached擴充的區別

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.