Posterous theme by Cory Watilo

ActiveSupport-JCache: Rails Cache on Google App Engine

ActiveSupport-JCache is a jRuby gem that lets you use Rails.cache in a jRuby on Rails on Google App Engine application.  The library uses the Java Memcache API to store/restore values.

Given that the library uses a standard JCache API, it should also work with other Java caches that offer that interface (i.e. Ehcache).  This, however, might change when I dive into the low-level Google App Engine APIs to implement explicit per-key expiration (expires_in).

Highlights

  • Rails Cache that works with Google App Engine
  • Wraps JCache API as JcacheStore
  • No per-key expiration (:expires_in) support

Installing

sudo jruby -S gem install activesupport-jcache

Configuring

In your config/environment.rb, add the following:

config.gem "activesupport-jcache", :lib => 'jcache_store'
config.cache_store = :jcache_store

Source:

The source is at http://github.com/rykov/activesupport-jcache

Demo on Google App Engine:

Try the demo at http://pagerduty.missingfeature.com

Without caching, the slowest part of this app was normalizing a list of latencies for display via Google Charts API.  When I started caching that data, render times went from over 3 seconds to around 500-600ms.  More information about the demo.