How to install Memcached on Win 7 + WAMP Server, the simplest way of all

Install memcached on wampYou can reach source code of memcached from its official web site. Since it is hard to compile memcached from its source code on Windows platforms, we will use a precompiled package (created for Win 7 + PHP 5.3). Download package from here and extract into C:\wamp\bin folder beside other services. Note that, memcached is a service just like MySQL and you have to connect memcached in order to use it.

- First of all, we have to install memcached as a service. So, open command prompt as administrator in folder C:\wamp\bin\memcached and run:

memcached -d install

- Start the memcached service by running:

memcached -d start

- You can verify if memcached is running by executing this command (You have to see full path of memcached.exe):

wmic process get description, executablepath | findstr memcached.exe

Install PHP Memcache extension (php_memcache.dll)

- If you don’t have php_memcache.dll in folder C:\wamp\bin\php\php5.x\ext, download it from here and extract into this directory.

- Open php configuration file php.ini from C:\wamp\bin\apache\Apache2.x\bin directory, and add the following line to the end of Dynamic Extensions block which lies between lines 920 and 990 roughly.

extension=php_memcache.dll

- Restart all services of Wamp Server through the system tray menu.

Testing Memcached with PHP

< ?php

$memcache = new Memcache;
$memcache->connect('localhost', 11211)
        or die
("Could not connect");
$version = $memcache->getVersion();
echo "Server's version: " . $version . "\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)\n";
$get_result = $memcache->get('key');
echo "Data from the cache:\n";
var_dump($get_result);

?>

added 4 years ago

- What does chess ELO ratings mean?
- WAMP Mysqli: Your password has expired
- Search Engine optimization: Google's 200 Ranking Factors
- MySQL Dump/Restore, Dumping MySQL Database and Tables using MysqlDump command
- iPhone 4S vs iPhone 5 vs Samsung Galaxy S3 comparison results
- Source Code of Matrix Multiplication
- How to Install Oracle Java on Ubuntu Linux? Java Performance Problems
- How to create your own PHP caching system? A simple example
- What is CSS and why is it useful?
- Domain Life Cycle
- How to Use a Router as a Repeater?
- Comparison of Random Functions According to their Exploration Performance (STL, .NET, Java)
- How to install Memcached on Win 7 + WAMP Server, the simplest way of all
- How to draw double buffered in C# or Java using GDI+
- How to restart page numbering for each chapter in Word 2007 – 2010
- How to recover Ubuntu after installing Windows using Ubuntu live cd