Install, Configure & Running Memcache in Windows as Service
Installing memcache server in windows is a little bit complicated compared to how it can be done in *nix since theres not yet available ready to use package for win32.
Luckily i found the compiled memcached for win32 (exe) which was made by jellycan, within this exe file you can install configure and running memcached as a service in your windows environment, here are how i made it:
*** updated ****
Newer version available at northscale, thanks to Matt Ingenthron for pointing this.
Installation
- download the memcached compiled file at jellycan website (choose: win32 binary)
- from windows command line running with administrator privileges, locate to memcached exe file
- execute memcached.exe -d install
- execute memcached.exe -d start
thats it now you have memcached services running on your server, by default it is listen to TCP port 11211 with 64 Mb memory limit. Configuring memcached also pretty simple you can uninstall the service and re-install it using your own parameters
Configuration
- memcached.exe -d uninstall
- memcached.exe -d install -m 512 -p 8081 (running with 512 mb memory limit, listening to TCP PORT 8081)
- memcached.exe -d start
the complete available parameters as follow:
- -p [num] TCP port number to listen on (default: 11211)
- -U [num] UDP port number to listen on (default: 0, off)
- -s [file] unix socket path to listen on (disables network support)
- -a [mask] access mask for unix socket, in octal (default 0700)
- -l [ip address] interface to listen on, default is INDRR_ANY
- -d start tell memcached to start
- -d restart tell running memcached to do a graceful restart
- -d stop|shutdown tell running memcached to shutdown
- -d install install memcached service
- -d uninstall uninstall memcached service
- -r maximize core file limit
- -u [username] assume identity of (only when run as root)
- -m [num]] max memory to use for items in megabytes, default is 64 MB
- -M return error on memory exhausted (rather than removing items)
- -c [num] max simultaneous connections, default is 1024
- -k lock down all paged memory.
- -v verbose (print errors/warnings while in event loop)
- -vv very verbose (also print client commands/reponses)
- -h print this help and exit
- -i print memcached and libevent license
- -b run a managed instanced (mnemonic: buckets)
- -P [file]] save PID in , only used with -d option
- -f [factor] chunk size growth factor, default 1.25
- -n [bytes]] minimum space allocated for key+value+flags, default 48
PHP memcached extension
To have PHP running with memcached extension, below are how i made it:
- download the php_memcached extension for win32 (php_memcache.dll) (if its not your in your php ext directory), i download it from here
- move it to your php extension directory
- edit your php.ini, add extension into it (extension=php_memcache.dll)
- save php.ini
- restart apache (net start apache_service_name)
PHP memcached test
Use code below to test your installation
$m = new Memcache;
$m->connect('localhost', 8081) or die ("Could not connect to memcached server");
$version = $m->getVersion();
echo "Memcached Server's version: ".$version."<br/>\n";
$o = new stdClass;
$o->attr = array('testing',234,'storing','another string');
$m->set('unique_key', $o, false, 30) or die ("Could not save cached data");
echo "Storing data for 30 seconds<br/>\n";
$r = $m->get('unique_key');
echo "Loaded ata from the cache:<br/>\n";
var_dump($r);
unset($m);





thank you for your tutorials
thank you for pointing the newer source, link updated
That’s a very, very old memcached. NorthScale has a much newer one and did a recent port. You can find it here:
http://labs.northscale.com/memcached-packages/