I've been playing about a bit with memcached, and have just checked into
the unstable branch some initial experimental code to use it to cache
user data (for logged in users) and individual lookups in the LinkCache.
Not very efficient, not very complete, just trying things out.
The PHP memcached client class is under GPL, and I've just included a
copy in for convenience. If we don't tell it to connect, all requests
become no-ops, so we can simply ask it for data, and on a memcached-less
installation we'll always immediately fall back to the database.
Note that the client requires socket support, which generally means
recompiling PHP with --enable-sockets. If disabled it shouldn't get to
any of the socket calls, so it should run fine without memcached enabled
on a stock socketless PHP.
See docs/memcached.doc for more details.
(I've also changed User::loadFromSession() to be a static class method
that returns an instance of User, rather than something that's run on a
newly created instance. This way we can just dump a serialized object to
the cache and get it back intact.)
I haven't thoroughly tested things at this point, but in brief it seems
to work. Note: performance _sucks_ with the stock memcached 1.1.8; use
the prerelease snapshot of 1.1.9:
http://lists.danga.com/pipermail/memcached/2003-August/000092.html
-- brion vibber (brion @
pobox.com)