tar -zxvf memcached-1.1.11.tar.gz

cd memcached-1.1.11 ./configure

make && make install



三、memcached的启动:

memcached -d -m 64 -l 192.168.241.195 -p 11212

启动的这个memcached为一个后台守护进程模式(-d), 然后缓存的空间为64M(-m), 监听(-l)服务器192.168.241.195的11212号端口(-p). 其实memcached的参数也非常的有限,可使用了memcached -h命令查看.

四、客户端安装

1、windows

下载相应的pecl包,将memcache.dll复制的ext目录,并在php.ini中加载

2、linux

 

cd php/bin

./pecl install memcache



在php.ini中指定extension_dir,并加载生成的memcache.so文件(一般在pear目录)

五、PHP API

 

<?php

connect('localhost', 11211) or die ("connect fail");

$version = $memcache->getVersion();

echo "Server's version: ".$version;

$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)";

$get_result = $memcache->get('key');

echo "Data from the cache:\n";

var_dump($get_result);

?>



相关文章:

  • 2021-06-18
  • 2022-01-08
  • 2022-12-23
  • 2022-12-23
  • 2021-10-19
  • 2021-12-13
  • 2022-01-21
  • 2021-12-15
猜你喜欢
  • 2021-09-01
  • 2022-01-11
  • 2021-05-30
  • 2021-12-11
相关资源
相似解决方案