-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME
More file actions
30 lines (21 loc) · 693 Bytes
/
Copy pathREADME
File metadata and controls
30 lines (21 loc) · 693 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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