I was having some caching issues earlier that I concluded were memcache-related. The memcache terminology is confusing: 'memcache' is the colloquial name, 'memcached' is the daemon, and php has both memcache and memcached extensions. The memcache module for Drupal supports both, but recommends the memcached version. I was running the other one, so I decided to switch to see if that would fix my problems.
The swap was harder than I expected, so here's how I did it, in case anyone else wants to do the same. This assumes you already have the daemon and old memcache library working correctly.
First try the simple method. This didn't work for me because I didn't have libmemcached installed. If it works for you, you're lucky:
sudo pecl install memcached
(I specified the version, memcached-1.0.2, to make sure I got the latest stable release, but that number might change by the time you read this.)
Anyway, that didn't work for me - I got an error, Can't find libmemcached headers". The documentation specifies a --with-libmemcached-dir parameter to handle this. But I didn't have the library installed anywhere, so I had to install it. (Fully install it, not just download it.)
Using /opt to hold the files, the latest version of libmemcached, and running as root (otherwise add sudo to each line, or at least to the make install step).
cd /opt
wget http://launchpad.net/libmemcached/1.0/0.40a/+download/libmemcached-0.40.tar.gz
tar -xzvf libmemcached-0.40.tar.gz
cd libmemcached-0.40
./configure
make
make install
Now try the simple method again: sudo pecl install memcached. If that still doesn't work, specify the directory manually:
cd /opt
pecl download memcached-1.0.2
tar zxvf memcached-1.0.2.tgz
cd memcached-1.0.2
phpize
./configure --with-libmemcached-dir=/opt/libmemcached-0.40/libmemcached
make
make install
(Play around with the configure line there if it still fails. I tried 100 variations until I got it working - I think with pecl install after the full make install on libmemcached - but your results may vary.
If this worked, there should now be a memcached.so file in your PHP extensions directory.
Now for the php config: the documentation on memcached's runtime configuration is sparse. The Drupal module recommends setting memcache.hash_strategy="consistent", however, I'm not sure if this has any effect on memcached.so. In my setup there was a conf.d/memcache.ini file, symlinked to cli/conf.d (for command line config) and apache2/conf.d. I changed the extension call to the new file, removed extraneous configs that didn't seem to be documented anywhere, and set the hash_strategy for good measure. Then I checked the config with apache2ctl configtest (will differ by distro), that checked out, so I restarted apache. phpinfo() showed the new extension, my caching problem went away, and all seems well so far.