Howto Start Memcached and Enable php_memcache in WAMP

Start Memcached

WampDeveloper Pro comes with memcached located in folder:

Memcached can either be started:

A) Manually from the command-line:

memcached.exe -l -p 11211 -m 128 -t 4

B) Or by double-clicking entry “memcached” in WampDeveloper’s Applications Tab, in which case, WampDeveloper will run file:

The memcached server will run as long as the command-line window is open. The “-m” option specifies the size (in MB) of memory to use.

Enable php_memcache

To connect and talk to the memcached server via PHP code, PHP extension php_memcache must be loaded.

1. Edit file:

2. Uncomment section:


(* uncomment by removing “;”, section is located near end of file)

3. Save file and restart Apache.

Connecting To and Using memcached

Example PHP code to test the operation of the memcached server…


ini_set('display_errors', 1);

$memcache = memcache_connect('localhost', 11211);

// note - memcache_connect errors must be suppressed (@) for this code to be reached
if ($memcache === false)
	echo "Connection to memcached failed.";

// test string
$key_string = "string to store in memcached";

// test number
$key_number = 123;

// test array
$key_array  = Array(123, 345, 567);

// test object
$key_object = new StdClass;
$key_object->str_attr = 'test';
$key_object->int_attr = 123;

// store the values into memcached
$memcache->set("str_key", $key_string);
$memcache->set("num_key", $key_number);
$memcache->set("arr_key", $key_array);
$memcache->set("obj_key", $key_object);

// retrieve the values from memcached


4 thoughts on “Howto Start Memcached and Enable php_memcache in WAMP”

    1. There are two way you can do this.

      1. Use Windows Task Scheduler / Manager to run the bat file that starts memcached – when the computer boots:

      * There might be some options to run it in the background so the cmd windows does not show (select-able in Task Manager, or with some extra command or parameters in the bat file).

      2. Run memcached via a Service Wrapper such as:

      The reason it’s not possible to install memcached as a service directly is because its Service interface was removed from its codebase after version 1.3.4.

      And the info on the net about using “sc.exe” to create a service out of a regular program only applies to executables that have Service interfaces implemented.

  1. I can’t seem to get memcache to run when I downgrade to a lower version of PHP eg version 5.4

    Is this method of launching memcache supposed to work with older versions of PHP? It is currently only working with the default PHP 5.6.3 install for me…

    1. I can’t reproduce the issue you are having.

      I’ve switched from Apache 2.4 and PHP 5.6 down to Apache 2.2 and PHP 5.4.

      Loading the memcache PHP extension (php_memcache.dll), starting memcached (server), and using the above test file, everything worked as expected.

      1. Make sure you have loaded the php_memcache extension for PHP 5.4. All major PHP versions have their own separate php.ini file.

      2. Make sure your PHP version contains ext\php_memcache.dll file. Some versions might not. If not, download the proper version from –

      3. Check PHP’s general error log (Reliability Tab). If there is a warning message that PHP is not able to load php_memcache.dll:

      A. Right-click on the php_memcache.dll file, select Properties. In the General tab, at the bottom, if it is listed as Blocked (by Windows), click to Unblock it.

      B. Otherwise, you are using a PHP extension that does not match the PHP build type. Ex: Bits (32), Compiler/runtime (VC9), PHP branch (5.4), PHP type (PHP-Regular is TS, PHP-FCGI is NTS).

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>