How to install & run Memcached on Windows
- Download package from http://labs.northscale.com/memcached-packages/
- Unzip to your desired directory (c:\memcached_win32\ in my example)
Add memcached to the Windows services from the command line
1 |
c:\memcached_win32\memcached.exe -d install |
Then you can start or stop the memcached server as a service with
1 |
net start memcached net stop memcached |
To edit the memcached server configuration, open regedit and go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\memcached, then find and edit the ImagePath
1 |
"C:\memcached_win32\memcached.exe" -d runservice -m 256 -p 11210 |
Example running memcached with 256 M and on port 11210
Using Memcached telnet interface
You can communicate with memcached server (localhost or distant) by opening a telnet session.
Memcached text protocol can be found here
It’s a bit confusing, but here some examples
Connecting to server :
1 |
> telnet localhost 11211 |
Server stats :
1 |
> stats STAT pid 14550 STAT uptime 2530 [a lot of line...] END |
Slabs stats :
1 |
> stats slabs STAT 1:chunk_size 80 [a lot of line...] END |
Items stats :
1 |
> stats items STAT items:1:number 1 [a lot of line...] END |
Set command :
1 |
> set key 0 900 13 > data_to_store STORED |
Details on set command :
set <key> <flags> <exptime> <bytes> with <bytes> = number of bytes of data you want to store.
Get command :
1 |
> get END > get key VALUE key 0 13 data_to_store END |
Increment & decrement commands :
1 |
> set key 0 900 2 > 10 STORED > incr key 5 15 > decr key 2 13 > get key VALUE key 0 2 13 |
You can also use phpMemCacheAdmin to execute these command and monitor your queries
Other Memcached Resources
You can find a lot of Memcached resources on this Memcached resources page.
Thanks, nice post