问题
i installed memcached and I also started the service by typing net start "memcached Server" and it said the service already started so i restarted apache and tried a couple of codes for using memcached:
<?php
//phpinfo();
$memcache = new Memcache;
$memcache->connect("localhost",11211); //change if necessary
$tempArray = array('fish', 'cow', 'demon');
$temp = serialize($testArray);
$memcache->add("key", $temp, 60);
print_r(unserialize($memcache->get("key")));
?>
but it gives an error:Fatal error: Class 'Memcache' not found in C:\wamp\www\temp.php on line 3
does this mean memcache is not started or anything else? i have not done anything except installing and starting the service do i need to do anything else like specifying The RAM and adding the server or anything else? I am using wamp server.
回答1:
Here are the steps that worked for me:
Url: How to enable memcache in WAMP
Needed Files
memcached.exe Direct Link
MSVCP71.DLL Windows DLL Files
msvcr71.dll
php_memcache.dll Working memcache for PHP 5.3.4
Steps
Copy MSVCP71.DLL, msvcr71.dll to C:\windows\sysWOW64
Copy memcached.exe into C:\memcached
Click Windows-Key
Type: CMD
press: Ctrl-Shift-Enter
Choose yes
type: C:\memcached\memcached.exe -d install
type: C:\memcached\memcached.exe -d start
Copy php_memcache.dll to C:\wamp\bin\php\php5.3.4\ext
Restart Apache using Wamp controls
Enable WAMP -> PHP -> PHP Extensios -> php_memcache
Then, I hit the phpinfo(), it wasn't display the memcache property. Any one can help me to install the wmap.
-- Thanks D.Jeeva
回答2:
Make sure you run the command prompt as an administrator as well if you aren't already. Also ensure that you have memcache enabled and that you have the proper dll. Use phpinfo() to check that memcache is enabled PHP side. Then just run a quick script to test if memcache is operational. Try the following, if you don't get hit with errors memcache is enabled.
<?php
$memcache = new Memcache;
$memcache->connect("localhost",11211); //change if necessary
$tempArray = array('fish', 'cow', 'demon');
$temp = serialize($testArray);
$memcache->add("key", $temp, 60);
print_r(unserialize($memcache->get("key")));
?>
回答3:
The Memcached service is not enough. By itself it has nothing to do with PHP and is not easily usable from PHP. To make it usable by PHP you also need either the Memcache or Memcached PHP extension which will handle communication with the service. It looks like you intend to use Memcache.
The PHP manual explains how to install PECL extensions on windows. WAMP may have an easier mechanism, I'm not sure as I'm not familiar with WAMP.
Edit
I found this blog post about installing Memcached to work with PHP on WAMP though. It could prove helpful. It looks like the extension is probably already available as a .dll
file on your computer somewhere, and you just need to edit your php.ini
file to include the extension and then restart Apache.
回答4:
I faced the exact same issue.
In my case the problem was that i was running on a 64-bit
system but i downloaded the 32-bit
memcache dll file.
After I downloaded Memcache 2.2.6 VC9 x64 Thread Safe
来源:https://stackoverflow.com/questions/10809101/memcache-not-working-on-windows-7