JRuby MemCache Client Gem

I wrote a post about using the jruby_memcache_client Rails plugin to manage sessions. Since then, Abhi Yerra made a fork of Ikai Lan's repository and turned it into a gem. I promptly merged his changes into my repository and I am now publishing my own version of the gem (with a few minor changes).

The new JRuby MemCache Client Gem is API compatible with the Ruby MemCache Client. You should now be able to install the gem into your application and use it directly.

Installing The Gem

You need to add github as a source for gems before you can install the new gem. Thsi is a simple one time command to run:

gem sources -a http://gems.github.com The next step is to install the gem as usual:

jruby -S gem install fredjean-jruby-memcache-client --remote

Using the JRuby MemCache Client Gem

One way to use the JRuby MemCache Client is to add the following to your environment.rb:
memcache_options = {
:namespace => 'fortaleza:production_live:'
memcached_servers = [ ENV['MEMCACHED_LOCATION'] || '']

# Constant used by libs
CACHE = MemCache.new memcached_servers, memcache_options

You will then be able to configure Rails to use the :mem_cache_store for both session and cache store.