How to install memcache on windows

Check your operating system whether 32bit or 64 bit. Based on that you need to download the binary version.

  1. 64bit Os – http://s3.amazonaws.com/downloads.northscale.com/memcached-win64-1.4.4-14.zip

  2. 32bit Os – http://code.jellycan.com/memcached/

  • Place the binary file on C or D location
  • Now Run the Command Prompt as Administrator – type the cmd –  C:/memcached/memcached.exe  -d install
  • Once Installed, Start the service – C:\memcached\memcached.exe -d start
  • Verify the service running properly on Start- > Run -> services.msc
  • Check your php extensions directory for php_memcache.dll
  • If you don’t have it, Download http://pecl.php.net/package/memcache/3.0.8/windows
  • Now Edit the Php.ini file and add following lines at extension section
  1. extension=php_memcache.dll
  2. Restart your apache server and Now we are good go.

If you are using Drupal then add below lines to settings.php

$conf['cache_backends'][] = 'sites/all/modules/contrib/memcache/memcache.inc';
$conf['cache_default_class'] = 'MemCacheDrupal';
$conf['cache_class_cache_form'] = 'DrupalDatabaseCache';

you can check the memcahce settings at “admin/reports/memcache”

 

If you are using Core php then use below code for checking memcache working or not.

<?php
$memcache = new Memcache;
$memcache->connect('localhost', 11211) or die ("Could not connect");
$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);
?>
Advertisements

What you think ? Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s