hongleimi 发表于 2018-6-27 06:36:17

windows php的Memcache安装和使用方法

  下载 :memcached.exe
  解压到 http://blog.51cto.com/wuhai/../attachment/201208/171052566.png
  下载:php_memcache.dll
把它放入php文件夹的ext目录中。在php.ini加入一行引用扩展,代码如下:extension=php_memcache.dllhttp://blog.51cto.com/wuhai/../attachment/201208/171144752.png
  重启Apache服务器
  然后查看一下phpinfo
http://blog.51cto.com/wuhai/../attachment/201208/171440780.png
  可以找到memcache信息 说明安装成功
  测试
  启动memcached: 双击E:\wamp\Memcached\memcached.exe 不要关闭窗口 关闭服务停止
  代码
  <?php
  $memcache = new Memcache;
  $memcache->connect("localhost", 11211);
  $version = $memcache->getVersion();
  echo "Server's version: ".$version."<br/>\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)<br/>\n";
  $get_result = $memcache->get('key');
  echo "Data from the cache:<br/>\n";
  var_dump($get_result);
  ?>
http://blog.51cto.com/wuhai/../attachment/201208/171716565.png
页: [1]
查看完整版本: windows php的Memcache安装和使用方法