methodmissing / query_memcached_legacy forked from ferblape/query_memcached

A replacement for ActiveRecord query_cache that a adds a Memcache layer for persistence of the query's cache

This URL has Read+Write access

methodmissing (author)
Sun Dec 21 10:11:57 -0800 2008
commit  0256b97c01952dfd3705bc92d6453d761242be71
tree    eab2346fdb2d4c7b5265d1f753e5a4dac57517d9
parent  eaaf197a18c72125e5fd96a36dc40e1c1a8a6caa
name age message
file .gitignore Loading commit data...
file MIT-LICENSE Tue Aug 05 09:47:39 -0700 2008 Cleaned files and dirs [ferblape]
file README
file RUNNING_TESTS
file Rakefile Tue Aug 05 09:47:39 -0700 2008 Cleaned files and dirs [ferblape]
file TODO
file init.rb
directory lib/
directory test/
README
= QueryMemcached

http://github.com/ferblape/query_memcached

== Install

In the root directory of your project:

script/plugin install git://github.com/ferblape/query_memcached.git

If you want to install it like a module you can follow this post, adapting the URLs to this plugin:

http://woss.name/2008/04/09/using-git-submodules-to-track-vendorrails/

== Requirements

  - Rails >= 2.1
  - memcache-client gem (maybe it will work also in memcached gem by fauna, see below)
  - MySQL (other adapters will not work until the execute method of adapter be redefined)

== Description

This plugin tries to replace ActiveRecord query_cache, adding a Memcache layer for persistence of the query's cache 
between requests. 

It is, instead of saving all the SQL query's results in memory each request you save them into Memcached, so you have 
them all the time.

For expiring this cache, each Memcached key contains a sumatory of all the version numbers of the tables involved in the 
query. If one of that tables is modified, then the version number for that table is increased.

For example, the query below involves the table items and the table places:

  SELECT * from items INNER JOIN places ON places.item_id = item.id WHERE (item.created_at >= '2008-02-02 00:00:00')

The idea behind this is way of create and expire cache was inspired by the post The Secret to Memcached 
[http://blog.leetsoft.com/2007/5/22/the-secret-to-memcached] by Tobias Lütke.

For this plugin to work it's supposed that your ActionController cache store configured is mem_cache_store. In not the 
plugin will not allow your application to start, raising an exception.

== Known issues

  - You can get race conditions in the version keys of tables stored in Memcached
  
== Running plugin tests

The tests of this plugin are not so standard so I decided to wrote a very explicative instructions in a file apart named 
RUNNING_TESTS

== TODO

There is a list of pending features, bugs, and so on in a file named TODO.

Any comments and suggestions are welcome.

== Another comments

It's so easy to adapt the plugin for Rails version 2.0.2 if you change the cache variable for another instantiated with 
the memcache-client.

Also, it is possible to run in Rails >= 1.2.4 if you change the plugin query_cache 
[http://agilewebdevelopment.com/plugins/query_cache] with the changes of query_memcached.

== Special Thanks

  - Raul Murciano [http://raul.murciano.net/] for helping to adapt the plugin to Rails 2.1
  - methodmissing [http://blog.methodmissing.com/] for some fresh ideas, lock library and correct some mistakes

Copyright (c) 2008 [Fernando Blat], released under the MIT license