memcached 安装测试

阅读更多
http://www.monkey.org/~provos/libevent/
https://github.com/downloads/libevent/libevent/libevent-2.0.18-stable.tar.gz

http://www.danga.com/memcached/dist/
http://memcached.googlecode.com/files/memcached-1.4.13.tar.gz




wget -r -np -nd --accept=gz --no-check-certificate
-np means no parent directory
-nd means don't construct local directory structure
--accept=gz means only download .gz files in the directory
http://hi.baidu.com/yss1983/blog/item/b875571112904344f819b8c3.html


# tar -xzf libevent-1.1a.tar.gz
# cd libevent-1.1a
# ./configure --prefix=/usr
# make
# make install
# cd ..
# tar -xzf memcached-1.1.12.tar.gz
# cd memcached-1.1.12
# ./configure --prefix=/usr
# make
# make install


/usr/bin/memcached -d -m 256 -l 192.168.1.1 -p 11211 -u www


/usr/bin/memcached -d -m 128 -p 11211 -u www



参数解释:

-d 以守护程序(daemon)方式运行 memcached;
-m 设置 memcached 可以使用的内存大小,单位为 M;
-l 设置监听的 IP 地址,如果是本机的话,通常可以不设置此参数;
-p 设置监听的端口,默认为 11211,所以也可以不设置此参数;
-u 指定用户,如果当前为 root 的话,需要使用此参数指定用户


www.cnblogs.com___lstone/articles/890960.html
www.ningoo.net___html/2009/use_memcached_in_php.html




$memcache = new Memcache;
$memcache->connect('127.0.0.1', 11211) or die ("Could not connect");
$version = $memcache->getVersion();
echo "Server's version: ".$version."\n";
$tmp_object = new stdClass;
$tmp_object->str_attr = 'test';
$tmp_object->int_attr = 123;
$memcache->set('key', $tmp_object, false, 10) or die ("Failed to save data at the server");
echo "Store data in the cache (data will expire in 10 seconds)\n";
$get_result = $memcache->get('key');
echo "Data from the cache:\n";
var_dump($get_result);
?>

你可能感兴趣的:(memcached 安装测试)