简体   繁体   English

在Amazaon EC2上将Memcached与PHP结合使用

[英]Using Memcached with PHP on Amazaon EC2

I have installed and started memcached service on my Amazon EC2 Instance. 我已经在Amazon EC2实例上安装并启动了memcached服务。 When I visit my phpinfo page http://verygoodtrips.com/phpinfo.php it shows the entries for Memcached 当我访问我的phpinfo页面http://verygoodtrips.com/phpinfo.php时,它显示了Memcached的条目

Now when I am trying to use Memcache in my php using the following code 现在,当我尝试使用以下代码在PHP中使用Memcache时

$memcache = new Memcache;
  $key = md5('Unique'); // Unique Words
  $memcache->set($key, "Hello", MEMCACHE_COMPRESSED, 1200);
  print_r($memcache->get($key));

Here's the php page with above source code http://verygoodtrips.com/memcache.php 这是上面带有源代码的php页面http://verygoodtrips.com/memcache.php

I am getting Internal Server Error (500). 我收到内部服务器错误(500)。 I am new to using Memcached, so it would be nice if someone can point me in right direction 我是使用Memcached的新手,所以如果有人可以向我指出正确的方向,那就太好了

It's a bit confusing at first but there's both Memcache and Memcached. 起初有点令人困惑,但同时有Memcache和Memcached。

 $cache = new Memcached();
 $key = md5('Unique'); // Unique Words
 $cache->set($key, "Hello", 1200);
 print_r($cache->get($key));

And for ease: http://www.php.net/manual/en/class.memcached.php 为了简便起见: http : //www.php.net/manual/zh/class.memcached.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM