ºìÁªLinuxÃÅ»§
Linux°ïÖú

LinuxÏ»º´æ·þÎñÆ÷µÄÓ¦ÓÃ

·¢²¼Ê±¼ä:2006-08-08 10:02:07À´Ô´:ºìÁª×÷Õß:ĪÞÈ
¡¡¡¡ÕªÒª£ºÓÉÓÚÊý¾Ý¿â´æ´¢µÄÊý¾ÝÁ¿Ô½À´Ô½´ó£¬²éѯËÙ¶ÈÒ²¾Í±äµÄÔ½À´Ô½Âý£¬Òò´Ë¾ÍÓÐÁË»º´æ·þÎñÆ÷Ó¦ÓõıØÒª£¬±¾ÎÄÊǽéÉÜMemcachedµÄ°²×°ÒÔ¼°¼òµ¥µÄʹÓÃ

¡¡¡¡±¾ÎÄÖ»½éÉÜmemcachedµÄPHPµÄAPI£¬Ïë²é¿´ÆäËû¹ØÓÚMemcachedµÄAPIÎĵµ°¸£¬Çë·ÃÎÊ http://www.danga.com/memcached/

Ŀ¼
Ò»¡¢»·¾³ÐèÇó
¶þ¡¢ÏÂÔØÏà¹ØÈí¼þ
Èý¡¢°²×°ºÍÅäÖÃ

1¡¢°²×°Memcached
2¡¢°²×°memcache PHPÄ£¿é
3¡¢²âÊԽű¾
ËÄ¡¢¹ØÓÚ±¾ÎÄ

++++++++++++++++++++++++++++++++++++++++
ÕýÎÄ
++++++++++++++++++++++++++++++++++++++++

Ò»¡¢»·¾³ÐèÇó

¡¡¡¡°²×°MemcachedÐèÒªlibevent¿âµÄÖ§³Ö£¬ËùÒÔÇëÔÚ°²×°Memcached֮ǰ¼ì²éÓÐûÓа²×°libevent¡£²âÊÔ»·¾³»¹ÐèÒªPHPµÄÖ§³Ö£¬±¾ÎļÙÉèPHPÒѾ­°²×°µ½/usr/local/phpĿ¼Ï£¬Ò²¾ÍÊÇÔÚ±àÒëPHPµÄʱºòʹÓÃperfix²ÎÊýÖ¸¶¨Ä¿Â¼(--prefix= /usr/local/php)

¶þ¡¢ÏÂÔØÏà¹ØÈí¼þ

MemcachedÏÂÔصØÖ· http://www.danga.com/memcached/
memcache PHPÄ£¿éÏÂÔصØÖ· http://pecl.php.net/package/memcache ÍƼöʹÓÃ1.5°æ
libevent ÏÂÔصØÖ· http://www.monkey.org/~provos/libevent/
±¾ÎIJ»ÔÙ½²ÊöÈçºÎ°²×°libevent

Èý¡¢°²×°ºÍÅäÖÃ

1¡¢°²×°Memcached


root@tonyvicky:# tar vxzf memcached-1.1.12.tar.gz
root@tonyvicky:# cd memcached-1.1.12
root@tonyvicky:# ./configure --prefix=/usr/local/memcached
root@tonyvicky:# make
root@tonyvicky:# make install

°²×°ÍêÖ®ºóÒªÆô¶¯·þÎñ

root@tonyvicky:# cd /usr/local/memcached/bin
root@tonyvicky:# ./memcached -d -m 50 -p 11211 -u root

²ÎÊý˵Ã÷ -m Ö¸¶¨Ê¹ÓöàÉÙÕ׵Ļº´æ¿Õ¼ä£»-p Ö¸¶¨Òª¼àÌýµÄ¶Ë¿Ú£» -u Ö¸¶¨ÒÔÄĸöÓû§À´ÔËÐÐ

2¡¢°²×°memcache PHPÄ£¿é


root@tonyvicky:# tar vxzf memcache-1.5.tgz
root@tonyvicky:# cd memcache-1.5
root@tonyvicky:# /usr/local/php/bin/phpize
root@tonyvicky:# ./configure --enable-memcache --with-php-config=/usr/local/php/bin/php-config --with-zlib-dir
root@tonyvicky:# make
root@tonyvicky:# make install

°²×°Íêºó»áÓÐÀàËÆÕâÑùµÄÌáʾ£º

Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20050922/

°ÑÕâ¸ö¼Çס
È»ºóÐÞ¸Äphp.ini
°Ñ

extension_dir = "./"

ÐÞ¸ÄΪ

extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20050922/"

²¢Ìí¼ÓÒ»ÐÐ

extension=memcache.so

3¡¢²âÊԽű¾

×Ô¼ºÐ´Ò»¸öPHP³ÌÐò²âÊÔһϰÉ


$memcache = new Memcache; //´´½¨Ò»¸ömemcache¶ÔÏó
$memcache->connect('localhost', 11211) or die ("Could not connect"); //Á¬½ÓMemcached·þÎñÆ÷
$memcache->set('key', 'test'); //ÉèÖÃÒ»¸ö±äÁ¿µ½ÄÚ´æÖУ¬Ãû³ÆÊÇkey ÖµÊÇtest
$get_value = $memcache->get('key'); //´ÓÄÚ´æÖÐÈ¡³ökeyµÄÖµ
echo $get_value;
?>

ËÄ¡¢¹ØÓÚ±¾ÎÄ
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 1 ÌõÆÀÂÛ

  1. iLove.Rain ÓÚ 2006-08-09 00:07:31·¢±í:

    ÊܽÌÁË