安装/配置
在线手册:中文 英文
PHP手册

安装

安装此 PECL 扩展相关的信息可在手册中标题为 PECL 扩展的安装 章节中找到。另外的信息,如新的发行版本、下载、源文件、 Additional information such as new releases,维护人员信息及变更日志等,都在此处: » http://pecl.php.net/package/memcached.

如果libmemcached被安装在一个非标准路径,使用--with-libmemcached-dir=DIR 来指定路径,DIR就是libmemcached安装时的prefix参数。这个路径需要包含文件include/libmemcached/memcached.h

如果要支持压缩就需要zlib。对于非标准安装的zlib库,使用--with-zlib-dir=DIR 来指定zlib安装路径,DIR就是zib安装时的prefix参数。

session处理器的支持默认是开启的。如果要关闭它,使用选项--disable-memcached-session


安装/配置
在线手册:中文 英文
PHP手册
PHP手册 - N: 安装

用户评论:

qeremy [at] gmail [dot] com (22-Feb-2012 05:32)

Do not lose your time to install it on Ubuntu just trying "sudo apt-get install php5-memcached". There is something you need to do that sure installing memcached. Anyway...

Step 1.
$ sudo apt-get install memcached
Step 2.
$ sudo apt-get install php5-memcached
Step 3.
$ sudo /etc/init.d/apache2 restart

Ready!

What about some test?

error_reporting(E_ALL & ~E_NOTICE);

$mc = new Memcached();
$mc->addServer("localhost", 11211);

$mc->set("foo", "Hello!");
$mc->set("bar", "Memcached...");

$arr = array(
    $mc->get("foo"),
    $mc->get("bar")
);
var_dump($arr);

Hoping to help someone.
~Kerem

petermiller1986 att gmail dotttttttt com (11-Feb-2012 03:09)

i'm planning on using membase for my website and i was really struggling to install the memcashed php client on ubuntu with pear, but actually there is an easier way:

$ sudo apt-get install php5-memcached

you dont even need to install the membase server first - this can be done afterwards. hope this helps someone!

Loreto Parisi (22-Sep-2010 01:44)

memcached 1.0.1 will compile against libmemcached 0.34.

Due to bug http://pecl.php.net/bugs/bug.php?id=17395
memcached 1.0.2 requires libmemcached 0.39+ instead.

gpuk at dasserver dot com (02-Mar-2010 09:50)

At present memcached-1.0.0 does not compile with libmemcached-0.38. This is apparently due to libmemcached chaning the API.

For evidence, see this bug: http://pecl.php.net/bugs/bug.php?id=17070

Note: I am encountering the same 'memcached_st' has no member named 'hash' error on a Debian lenny amd_64 box.

Clint Priest (09-Nov-2009 06:53)

If your server has --enable-json=shared as mine did, this extension requires you to have extension=json.so to load properly.