Tidbits

Things I have found myself repeating, and other ramblings.

Memcached Debugging

Here is a useful PHP tool for debugging Memcached. You will need this file – memcache.php.

Mac

Setup

If you do not have Apache running see the post Enable Apache on a Mac. Alternatively, try MAMP – adjust paths as necessary.

1
2
3
4
5
$ cd ~/
$ mkdir Sites
# move memcache.php to ~/Sites/
$ cd /etc/apache2
$ sudo vi httpd.conf

Search for ‘php’ – this line specifically

1
#LoadModule php5_module libexec/apache2/libphp5.so

Uncomment it (remove the leading ‘#’) and save file.

Put memcache.php in ~/Sites/. To hit it

1
http://localhost/~<username>/memcache.php

memcache.php has a username/password setup

1
2
username: memcache
password: password

Windows

If on Windows and not running Apache take a look at WAMP. In either case drop the PHP file in the appropriate place.

Telnet Debugging

For telnet to memcached

1
$ telnet localhost 11211

Quick overview of the most useful telnet commands

1
2
3
4
5
> stats #lists a bunch-o-stuff
> stats items #lists the slabs, example output. STAT items:3:number 1
#list the items in slab id 3 up to 100 items (doesn't seem to work if you leave off the last number, although it can be any number)
> stats cachedump 3 100
> version #version of memcached