cachecataz 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. data/Gemfile.lock +2 -0
  2. data/README.rdoc +15 -2
  3. data/VERSION +1 -1
  4. metadata +3 -3
data/Gemfile.lock CHANGED
@@ -9,6 +9,7 @@ GEM
9
9
  rake
10
10
  rake (0.8.7)
11
11
  rcov (0.9.9)
12
+ rcov (0.9.9-java)
12
13
  rspec (2.3.0)
13
14
  rspec-core (~> 2.3.0)
14
15
  rspec-expectations (~> 2.3.0)
@@ -19,6 +20,7 @@ GEM
19
20
  rspec-mocks (2.3.0)
20
21
 
21
22
  PLATFORMS
23
+ java
22
24
  ruby
23
25
 
24
26
  DEPENDENCIES
data/README.rdoc CHANGED
@@ -60,7 +60,7 @@ For the example above the namespace key would be "name:#{element.user_id}", whic
60
60
 
61
61
  Basic premise: An Element belongs_to a User and a Widget belongs_to a User as well. The "something" partial displays data primarily related to
62
62
  the Element but also displays data from the related Widget. I want to have a sweeper that observes changes in the Widget model and expires the
63
- namespace for the Element. (can be kinda confusing, but makes sense in the context of a cache that is model dependent.
63
+ namespace for the Element. (can be kinda confusing, but makes sense in the context of a cache that is model dependent.)
64
64
 
65
65
  Generate a cache key:
66
66
  # ** Model **
@@ -76,11 +76,24 @@ Generate a cache key:
76
76
  <% end %>
77
77
 
78
78
  # ** Observer **
79
- class WidgetObserver < ActiveRecord::Observer
79
+ class WidgetObserver < ActiveRecord::Observer
80
80
  after_update(widget)
81
81
  Element.expire_namespace(:user, widget.attributes) # can also just pass {:user_id => widget.user_id} as the scope_hash, scope requires :user_id
82
82
  end
83
83
  end
84
+
85
+ # ** Another Observer ** Why expire_fragment is available? not important
86
+ class ElementObserver < CacheSweepingObserver
87
+ after_update(element)
88
+ expire_fragment(element.cache_key(:user, :id)) # Will only expire a single key "0:user:1/12" if user_id == 1 and id == 12
89
+ end
90
+
91
+ after_create(element)
92
+ element.expire_namespace(:user) # will expire the entire namespace for cache_scope :user for user 1 if user_id ==1
93
+ end
94
+ end
95
+
96
+ # by default the scope_hash on any expire_namespace call for an instance is self.attributes
84
97
 
85
98
  == TODO
86
99
  post more info on how to use cachecataz with a cache that is not Rails.cache (it's very simple), but wanted to get the basics released
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cachecataz
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Brandon Dewitt