Memcached is an in-memory, distributed key-value store for random pieces of application data. It is useful for clustering and distributed caching and it (and similar tools) are becoming an increasingly common feature of large Web-based apps.
I don’t like Windows any more than the next guy when it comes to using it as a Server OS, but sometimes you’ve got no choice – maybe you work in an environment where Windows Server is the only option. *sigh*
Memcached is not something that you would generally install on Windows, (not for production anyhow), but it is possible to have it running happily as a native Windows service.
Here’s how –
- Download either the 32-bit or 64-bit Windows builds of Memcached from NorthScale
- Unzip the memcached build into a server folder, say “C:memcached”
- Run memcached.exe and ensure it starts. You should get a blank console window. Ctrl+C will close it, assuming all is well.
- To set it up as a native service we will download the Windows Server 2003 Resource Kit
- Install the Windows Resource Kit.
For clarity I’ll refer to the install location as “C:Program FilesWindows Resource KitsTools”, in reality it may be different. Substitute your install location as needed.
- Open a command prompt and change to your resource kit folder e.g. C:Program FilesWindows Resource KitsTools
- At the prompt:
instsrv Memcached "C:Program FilesWindows Resource KitsToolsSRVANY.EXE"
- Open Notepad and paste the following into it –
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINESYSTEMCurrentControlSetservicesMemcachedParameters] "Application"="c:\memcached\memcached.exe" "AppParameters"="-m 1024"
Adjust the path as necessary. You can add (or remove) memcached command line options with the “AppParameters” option.
- Save the file as “c:memcachedconfigservice.reg”
- Double click the file in Windows Explorer and merge the settings into the Registry.
- Start the service, e.g. “net start Memcached” at the command prompt
- You’re done!
Also, there is an alternative option – you can use the Java based clone of memcached, (the intuitively/unimaginatively) named jmemcached.
This can be used in conjunction with Java Service Wrapper to create Java-based Windows service which operates like the native memcached.