Rails MemCacheStore Fu
Or how to use the latest memcache-client (1.7.4 as of this writing) over the vendored copy in Rails and control the MemCacheStore initialization using the cache_fu/act_as_cached memcached.yml config file.
- get Mike Perham’s latest memcache-client on github or simply:
sudo gem install memcache-clientmake sure to remove any other memcache-client gems from your system.
- follow Mike’s instructions to performs brain surgery on the Ruby environment to override ActiveSupport memcache-client
- to control the MemCacheStore initialization using the options in your memcached.yml file, grab my memcached-config code from github
- include the following code in your environments/*.rb files:
unless (memcached_config = MemcachedConfig.new).disabled? memcached_options = memcached_config.options config.cache_store = :mem_cache_store, memcached_options.delete(:servers), memcached_options end
By using MemcachedConfig this way, all the recognized options by memcache-client in your memcached.yml config file, such as :namespace, will be used. You can also add specific memcache-client options such as :failover or :timeout in you memcached.yml.

Have you set this up for session storage?
Also, have you set this up with passenger (e.g. PhusionPassenger.on_event(:starting_worker_process))?
Thanks.
Also, have you tried this with a vendored version of the memcache-client gem?
Thanks.
@chris, I haven’t used it for session storage but it should just work. I did not try it with Passenger either.
As for a vendored version of the memcache-client gem, it should also just work. You can verify in script/console if the correct client has been installed using the following:
>> MemCache::VERSION
=> “1.7.4″
>> RAILS_CACHE.instance_variable_get(”@data”).class::VERSION
=> “1.7.4″
Colin.