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,
"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.
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.
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); ?>