Forum: Ruby on Rails [ANN] cached_model-1.0.1 ActiveRecords + memcache

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
58479f76374a3ba3c69b9804163f39f4?d=identicon&s=25 Eric Hodel (Guest)
on 2006-01-30 20:06
(Received via mailing list)
The new version of cached_model features bug fixes and tests!

Bugs fixed:

Updating a model no longer stores associations into the cache.  This
could cause strange, hard-to-debug bugs when an invalid set of
assocations was retrieved along with a cached model.

Reloading a model refreshes the cache.

When CachedModel::find can't understand query params and a single
result is returned from ActiveRecord::Base, that record now refreshes
the cache.

= CachedModel

Rubyforge Project:


== About

CachedModel stores Rails ActiveRecord objects in memcache allowing
for very
fast retrievals.  CachedModel uses the ActiveRecord::Locking to
ensure that
you don't perform multiple updates.

== Using CachedModel

First, install the cached_model gem:

   $ sudo gem install cached_model

Then set up memcache-client:

   $ tail -n 20  config/environments/production.rb
   memcache_options = {
     :c_threshold => 10_000,
     :compression => true,
     :debug => false,
     :namespace => 'my_rails_app',
     :readonly => false,
     :urlencode => false

   CACHE = memcache_options
   CACHE.servers = 'localhost:11211'

   session_options = {
     :database_manager => CGI::Session::MemCacheStore,
     :cache => CACHE,
     :session_domain => ''


You will need separate namespaces for production and development, if
memcache on the same machine.

Note that using memcache with tests will cause test failures, so set
memcache to be readonly for the test environment.

Then make Rails load the gem:

   $ tail -n 4 config/environment.rb
   # Include your application configuration below

   require_gem 'cached_model'

Then edit your ActiveRecord model to inherit from CachedModel instead of

   $ head -n 8 app/models/photo.rb
   # A Photo from Flickr.

   class Photo < CachedModel

     belongs_to :point
     belongs_to :route

Eric Hodel - -
This implementation is HODEL-HASH-9600 compliant
This topic is locked and can not be replied to.