How to install Memcache deamon on Windows


Step 1: Download:

Memcached 1.2.X

Memcached 1.2.4 for Windows (32 Bits) : memcached 1.2.4 win32.zip

Memcached 1.2.5 for Windows (32 Bits) : memcached 1.2.5 win32.zip

Memcached 1.2.6 for Windows (32 Bits) : memcached 1.2.6 win32.zip

Memcached 1.4.X

Memcached 1.4.2 for Windows (32 Bits) : memcached 1.4.2 win32.zip

Memcached 1.4.4 for Windows (32 Bits) : memcached 1.4.4 win32.rar

Memcached 1.4.5 for Windows (32 Bits) : memcached 1.4.5 win32.zip

Memcached 1.4.5 for Windows (64 Bits) : memcached 1.4.5 win64.zip

Note: with Windows 64bits, you can use memcached 1.4.5 win64.zip or memcached 1.4.5 win32.zip

download memcache for windows

Step 2: Unzip this filder to any folder like D:\memcached\

memcache deamon on windows

Step 3: Run this command:

sc create "Memcached11211" binPath= "D:\memcached\memcached.exe -d runservice -p 11211" DisplayName= "Memcached11211" start= auto

Result:

C:\Users\Administrator>sc create "Memcached11211" binPath= "D:\memcached\memcach
ed.exe -d runservice -p 11211" DisplayName= "Memcached11211" start= auto
[SC] CreateService SUCCESS

Now, you can use memcache, you can test with this code:

<?php

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

if ($memcache) {
	$memcache->set("str_key", "String to store in memcached");
	$memcache->set("num_key", 123);

	$object = new StdClass;
	$object->attribute = 'test';
	$memcache->set("obj_key", $object);

	$array = Array('assoc'=>123, 345, 567);
	$memcache->set("arr_key", $array);

	var_dump($memcache->get('str_key'));
	var_dump($memcache->get('num_key'));
	var_dump($memcache->get('obj_key'));
}
else {
	echo "Connection to memcached failed";
}
?>

1 Comment

Leave a Reply