Skip to content

Counter caching for ActiveRecord that can be hooked into your background processing architecture.

License

Notifications You must be signed in to change notification settings

betamatt/passive_counter_cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PassiveCounterCache
===================

Adds support for simple counter cache updating that can be hooked into background processing.  Rails counter caching is disabled
and a method is provided to update caches from a background process.


Example
=======

class Cart < ActiveRecord::Base
  has_many :wheels
end

class Wheel < ActiveRecord::Base
  belongs_to :cart, :passive_counter_cache => true
end

Create a cart and four wheels
>> c = Cart.create
>> 4.times do { c.wheels.create }

As part of a BackgroundRb (or similar) scheduled task execute:
>> PassiveCounterCache.update_all_caches!

>> c.reload!
>> c.wheel_count
=> 4

Copyright (c) 2009 Matt Griffin, released under the MIT license

About

Counter caching for ActiveRecord that can be hooked into your background processing architecture.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages