Using Memcached on Windows and Memcached telnet interface
By Cyrille Mahieux on Friday, April 16 2010, 19:44 - Memcached - Permalink
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
c:\memcached_win32\memcached.exe -d install
Then you can start or stop the memcached server as a service with
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
"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 :
> telnet localhost 11211
Server stats :
> stats STAT pid 14550 STAT uptime 2530 [a lot of line...] END
Slabs stats :
> stats slabs STAT 1:chunk_size 80 [a lot of line...] END
Items stats :
> stats items STAT items:1:number 1 [a lot of line...] END
Set command :
> 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 :
> get END > get key VALUE key 0 13 data_to_store END
Increment & decrement commands :
> 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.