Category:
A Brief Description , Now a days lots of websites like Wikipedia, Twitter, Youtube, Digg are using an open source, high-performance, distributed memory object caching system called Memcache or Memcached. Basically it provides a caching mechanism in the server side scripting. Here we are going to use it for PHP. From there website it's quite understandable that the distribution is mainly built for Linux environment. But lot of people are very much comfortable using the Windows environment. In this "How to" I'll tell how to install memcache in Windows 7. I'm using the wampserver version "WampServer2.1e-x32". It has PHP 5.3 with it. Installation Steps,
Step 1.
Step 2.
Step 3.
Step 4.
"your path to memcached.exe" -d install
For further help please refer to the image below.
Here you can face a problem. When you hit enter after writing the install command a dialog box can pop-up and say, The program can't install because MSVCR71.dll is missing from your computer. Like in my case,
To solve this please download the MSVCR71.dll. You can google it if you want or else click Here to download the dll file. Paste it in C:\Windows\system32 folder and then hit enter again in the install command and you have successfully installed the memcache.
Step 5.
Step 6.
Again none of these worked for me. So again into Google. After spending lot of hours I've finally got one. I'm providing it Here,so click then link and download. After download place the .dll file in your PHP extension directory. Generally for wamp it's the wamp\bin\php\php5.3.5\ext\. Then Open up php.ini file and paste in the extension section, extension=php_memcache.dll and restart wamp.
Testing,
Run this code to test the installation. If you see anything but errors, you are now using memcache!
<?php $memcache = new Memcache; $memcache->connect('localhost', 11211) or die ("Could not connect"); //Can Use 127.0.0.1 instead "localhost" $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); ?>



Comments
Thanks!
Submitted by Joel Milne (not verified) on
I tried using the same php_memcache.dll files you mentioned in your post and also found they did not work on Windows 7 with WAMP. Your download link worked like a charm, thanks!
Thanks Joel
Submitted by aneek on
Thanks Joel,
I really appreciate that my experiment with the memcache and it's installer and helper files came useful to you.
Thanks!
Submitted by Jason (not verified) on
Thanks! Ran into a small problem but worked around it easily.
I found that I had to place the MSVCR71.dll into C:\Windows\system instead of C:\Windows\system32
After copying the dll into the system32 folder, The installer would still complain that it was not found. So, I tried to register it manually and it complained the dll wasn't compatible (using Win 7 64bit on a VM). Moving it to the system folder instead worked like a charm though.
On a 64 bit Windows 7 you
Submitted by Resul (not verified) on
On a 64 bit Windows 7 you will have to copy the MSVCR71.dll files in C:\windows\sysWOW64
PERFECT solution
Submitted by Clinton Paquin (not verified) on
Couldn't have been more clear, thanks for the concise directions!
Works Perfectly
Submitted by Diego Toala (not verified) on
Hi , your file works perfectly on my wamp + Windows7. Thank you!
Kristina
Submitted by Kristina (not verified) on
Hi nice art! i'm Kristina and i add "Like" (facebook) to your article!
Great!
Submitted by gil (not verified) on
Thanks a lot... very helpful, clear and... BIG like =]
Add new comment