Code Monkey home page Code Monkey logo

record_cache's Introduction

RecordCache

RecordCache is a simple yet powerful extension to ActiveRecord that caches indexes and ActiveRecord models using MemCache. If you use it correctly, it will drastically reduce your database load.

Usage:

require 'record_cache'

class User < ActiveRecord
  record_cache :by => :id
  record_cache :id, :by => :username
end

# These will use the cache now.
User.find(1)
User.find_by_id(2)
User.find_all_by_username('chuck')

Invalidation is handled for you using callbacks. Be careful though if you modify records directly using SQL. Both update_all and delete_all handle invalidations for you, but other direct SQL will not.

Install:

gem install record_cache

Dependencies:

RecordCache is confirmed to work with Rails 2.3.9. It does not currently work with Rails 3.

License:

Copyright © 2009 Justin Balthrop, Geni.com; Published under The MIT License, see LICENSE

record_cache's People

Contributors

chrisjwu avatar ninjudd avatar raynes avatar stangel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

record_cache's Issues

Join forces with kasket :)

This seems to be very similar to kasket
kasket has a few more options and docs + works on rails 2-3.2,
so maybe a switch would be easy -> everybody can improve+fix a common codebase

record_cache doesn't work with AR associations

This is being passed in the keys to find_by_field:
{:select=>nil, :include=>nil, :conditions=>nil, :readonly=>nil}

NoMethodError: undefined method <<' for nil:NilClass from vendor/record_cache/lib/record_cache/index.rb:280:inget_records'
from vendor/record_cache/lib/record_cache/index.rb:277:in each' from vendor/record_cache/lib/record_cache/index.rb:277:inget_records'
from vendor/record_cache/lib/record_cache/index.rb:270:in each_slice' from vendor/record_cache/lib/record_cache/index.rb:270:inget_records'
from vendor/memcache/lib/memcache.rb:264:in get_some' from vendor/record_cache/lib/record_cache/index.rb:262:inget_records'
from vendor/memcache/lib/memcache.rb:101:in in_namespace' from vendor/record_cache/lib/record_cache/index.rb:256:inget_records'
from vendor/record_cache/lib/record_cache/index.rb:105:in find_by_field' from vendor/record_cache/lib/record_cache.rb:218:infind_by_facebook_uid'
from vendor/rails/activerecord/lib/active_record/associations/belongs_to_association.rb:49:in send' from vendor/rails/activerecord/lib/active_record/associations/belongs_to_association.rb:49:infind_targ

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.