redis_object 1.2.2 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Gemfile +5 -3
- data/lib/redis_object.rb +1 -1
- data/lib/redis_object/base.rb +2 -2
- data/lib/redis_object/ext/view_caching.rb +23 -5
- data/lib/redis_object/version.rb +1 -1
- data/spec/script_cache_spec.rb +2 -2
- data/spec/view_caching_spec.rb +7 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YzUwMjBmYTE3ZDljZGMxMmE4MzBlNmQ5ZDQxNmUxNTAyMDU0ZGEzZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZjRkOTMzMzI0ZGMwOWY1NDY0ZWUzMjg4ODhjZjc5NjVlYWRjNjY5Mw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Yjk2NWJhOGNlZTQ3ZWVkYzAzMTJkNDZmMTA0NDA1ZDNmN2Y3MmJkMGNjMWIw
|
10
|
+
MzMzZmU1NTc1MmZkMTkzYTdlMDgzZjNkMGVlOGNhMzZiOWY4YjQ2YTVlNjVj
|
11
|
+
YjAxOTNkMGY0NTgwZWE2MWZkNDk5Yzk4NTcxMzA1ZjUzM2Y2NWM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NWYyMmYxNzk2ZGJiYTQxOTYxYTM3NmNkOTg2MzY2NDJhNDFlOTUxNzQwZWMy
|
14
|
+
YmU3MTMyZDA4M2Y2N2QxMmI3OGQ3OWRhYjIyNDA2OTIzYTMxMjhlMWFhNWFm
|
15
|
+
MzNhOGRhMWRjN2MxMzQ4YWE1ODRlZTVkNTRhOGE2YmQ1ZDA4YWE=
|
data/Gemfile
CHANGED
data/lib/redis_object.rb
CHANGED
@@ -33,12 +33,12 @@ module Seabright
|
|
33
33
|
include Seabright::Types
|
34
34
|
include Seabright::DefaultValues
|
35
35
|
include Seabright::Collections
|
36
|
+
include Seabright::Triggers
|
36
37
|
include Seabright::Indices
|
37
38
|
include Seabright::Views
|
38
39
|
include Seabright::ViewCaching
|
39
40
|
include Seabright::Timestamps
|
40
41
|
include Seabright::History
|
41
|
-
include Seabright::Triggers
|
42
42
|
include Seabright::Benchmark
|
43
43
|
|
44
44
|
end
|
data/lib/redis_object/base.rb
CHANGED
@@ -177,10 +177,10 @@ module Seabright
|
|
177
177
|
super if sym == :class
|
178
178
|
if sym.to_s =~ SetPattern
|
179
179
|
return super if args.size > 1
|
180
|
-
set
|
180
|
+
send(:set,sym.to_s.gsub(SetPattern,'').to_sym,*args)
|
181
181
|
else
|
182
182
|
return super if !args.empty?
|
183
|
-
get
|
183
|
+
send(:get,sym)
|
184
184
|
end
|
185
185
|
end
|
186
186
|
|
@@ -34,8 +34,6 @@ module Seabright
|
|
34
34
|
|
35
35
|
def cache_view(name,opts=true)
|
36
36
|
cached_views[name.to_sym] = opts
|
37
|
-
intercept_views_for_caching!
|
38
|
-
set_up_invalidation!
|
39
37
|
end
|
40
38
|
alias_method :cache_named_view, :cache_view
|
41
39
|
|
@@ -175,7 +173,27 @@ module Seabright
|
|
175
173
|
end
|
176
174
|
end
|
177
175
|
|
178
|
-
|
176
|
+
def invalidated_by(obj,chain)
|
177
|
+
invalidate_cached_views!
|
178
|
+
end
|
179
|
+
|
180
|
+
def invalidated_set(cmd,k,v)
|
181
|
+
ret = send("uninvalidated_#{cmd}".to_sym,k,v)
|
182
|
+
invalidated_by_update!
|
183
|
+
ret
|
184
|
+
end
|
185
|
+
|
186
|
+
alias_method :uninvalidated_set, :set unless method_defined?(:uninvalidated_set)
|
187
|
+
def set(k,v)
|
188
|
+
invalidated_set(:set,k,v)
|
189
|
+
end
|
190
|
+
|
191
|
+
alias_method :uninvalidated_setnx, :setnx unless method_defined?(:uninvalidated_setnx)
|
192
|
+
def setnx(k,v)
|
193
|
+
invalidated_set(:setnx,k,v)
|
194
|
+
end
|
195
|
+
|
196
|
+
# trigger_on_update :invalidated_by_update!
|
179
197
|
trigger_on_reference :invalidated_by_reference!
|
180
198
|
|
181
199
|
end
|
@@ -202,7 +220,6 @@ module Seabright
|
|
202
220
|
|
203
221
|
def invalidate_upstream(*args)
|
204
222
|
@upstream_invalidations = (@upstream_invalidations || []) + args
|
205
|
-
set_up_invalidation!
|
206
223
|
end
|
207
224
|
|
208
225
|
def upstream_invalidations
|
@@ -219,7 +236,6 @@ module Seabright
|
|
219
236
|
|
220
237
|
def invalidate_downstream(*args)
|
221
238
|
@downstream_invalidations = (@downstream_invalidations || []) + args
|
222
|
-
set_up_invalidation!
|
223
239
|
end
|
224
240
|
|
225
241
|
def downstream_invalidations
|
@@ -252,6 +268,8 @@ module Seabright
|
|
252
268
|
|
253
269
|
def self.included(base)
|
254
270
|
base.extend(ClassMethods)
|
271
|
+
base.intercept_views_for_caching!
|
272
|
+
base.set_up_invalidation!
|
255
273
|
end
|
256
274
|
|
257
275
|
end
|
data/lib/redis_object/version.rb
CHANGED
data/spec/script_cache_spec.rb
CHANGED
@@ -26,9 +26,9 @@ module ScriptCacheSpec
|
|
26
26
|
GenericObject.recently_created.first.id.should eq("5")
|
27
27
|
GenericObject.indexed(:created_at,-1,false).to_a.last.id.should eq("4")
|
28
28
|
|
29
|
-
$ScriptSHAMap.keys.count
|
29
|
+
cnt = $ScriptSHAMap.keys.count
|
30
30
|
RedisObject.untrack_script :RevScript
|
31
|
-
$ScriptSHAMap.keys.count.should eq(
|
31
|
+
$ScriptSHAMap.keys.count.should eq(cnt-1)
|
32
32
|
|
33
33
|
end
|
34
34
|
|
data/spec/view_caching_spec.rb
CHANGED
@@ -34,7 +34,7 @@ module ViewCachingSpec
|
|
34
34
|
|
35
35
|
class Container < RedisObject
|
36
36
|
|
37
|
-
invalidate_downstream :
|
37
|
+
invalidate_downstream :typed_objects
|
38
38
|
|
39
39
|
end
|
40
40
|
|
@@ -96,9 +96,9 @@ module ViewCachingSpec
|
|
96
96
|
@obj.view_is_cached?(:aggregated).should eq(true)
|
97
97
|
|
98
98
|
@obj.set(:demolisher, "smash")
|
99
|
-
|
100
|
-
# @obj.view_is_cached?(:aggregated).should eq(false)
|
99
|
+
sleep 1
|
101
100
|
|
101
|
+
@obj.view_is_cached?(:aggregated).should eq(false)
|
102
102
|
|
103
103
|
end
|
104
104
|
|
@@ -109,20 +109,18 @@ module ViewCachingSpec
|
|
109
109
|
@obj.view_is_cached?(:aggregated).should eq(true)
|
110
110
|
|
111
111
|
@baby.set(:demolisher, "smash")
|
112
|
+
sleep 1
|
112
113
|
|
113
|
-
|
114
|
-
#
|
115
|
-
# TypedObject.find(@obj.id).view_is_cached?(:aggregated).should eq(false)
|
114
|
+
TypedObject.find(@obj.id).view_is_cached?(:aggregated).should eq(false)
|
116
115
|
|
117
116
|
@obj.view_as_hash(:aggregated).should be_a(Hash)
|
118
117
|
|
119
118
|
@obj.view_is_cached?(:aggregated).should eq(true)
|
120
119
|
|
121
120
|
@dad.set(:demolisher, "smash")
|
121
|
+
sleep 1
|
122
122
|
|
123
|
-
|
124
|
-
#
|
125
|
-
# TypedObject.find(@obj.id).view_is_cached?(:aggregated).should eq(false)
|
123
|
+
TypedObject.find(@obj.id).view_is_cached?(:aggregated).should eq(false)
|
126
124
|
|
127
125
|
end
|
128
126
|
|