I have a test site at AppFog running WordPress. Being the geek I am, I had to test MemCachier (you’ll find it in AppFog Add-Ons)

MemCachier manages and scales clusters of memcache servers so you can focus on your app. Memcache is commonly used to speed up page load time and increase scalability by allowing you to cache expensive database queries and view renders.

Using the Memcached Object Cache source code as a starting point it was rather simple to implement MemCachier, all I had to do was to modify WP_Object_Cache::close(), WP_Object_Cache::flush() and rewrite the WP_Object_Cache constructor (line 4-28):

// WP_Object_Cache constructor
function WP_Object_Cache() {


global $memcachier_servers;

if ( isset($memcachier_servers) )
$buckets = $memcachier_servers;
$buckets = array(
'default' => array(


foreach ( $buckets as $bucket => $servers) {
$this->mc[$bucket] = new MemcacheSASL;
foreach ( $servers as $server ) {
list ( $node, $port ) = explode(':', $server);

$this->mc[$bucket]->addServer($node, $port);
$this->mc[$bucket]->setSaslAuthData(getenv("MEMCACHIER_USERNAME"), getenv("MEMCACHIER_PASSWORD"));


global $blog_id, $table_prefix;
$this->global_prefix = '';
$this->blog_prefix = '';
if ( function_exists( 'is_multisite' ) ) {
$this->global_prefix = ( is_multisite() || defined('CUSTOM_USER_TABLE') && defined('CUSTOM_USER_META_TABLE') ) ? '' : $table_prefix;
$this->blog_prefix = ( is_multisite() ? $blog_id : $table_prefix ) . ':';

$this->cache_hits =& $this->stats['get'];
$this->cache_misses =& $this->stats['add'];


The instructions are simple, and although they’re catered specifically for AppFog, the MemCachier WordPress plugin will work in any of our supported partners. As long as you’ve configured the MEMCACHIER_SERVERS, MEMCACHIER_USERNAME, and MEMCACHIER_PASSWORD environment variables, the plugin will work.
MemCachier blog

  1. Add MemCachier to your WordPress site at AppFog
  2. Install the plugin by copying it to the plugins/memcachier folder
  3. Move plugins/memcachier/object-cache.php to wp-content/object-cache.php



  • Initial release


I’ve only changed the WP_Object_Cache constructor, so the credits goes to ryan and sivel for creating the excellent Memcached Object Cache, and ronnywang for PHPMemcacheSASL