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.

Testing:

# ensure memcached is installed and in the path

bundle exec rake test TEST_OPTS="--verbose --no-show-detail-immediately"

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

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.