simple_cacheable 1.4.0 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +3 -0
- data/Gemfile.lock +12 -10
- data/cacheable.gemspec +2 -2
- data/lib/cacheable/types/association_cache.rb +16 -8
- data/lib/cacheable/version.rb +1 -1
- data/lib/cacheable.rb +1 -1
- data/spec/cacheable/types/association_cache_spec.rb +22 -0
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82a842613fa2c2177a47105e827c286a0c959e4e
|
4
|
+
data.tar.gz: 21bcf0508eb353b7f4899392f47951138a4a3f3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8aef917182c022c49718748fef29f2b1b9152526d2de85021ccff9082386d3620ef867fe677a5c087c99ccbdb63cf3b4067a032db497ab6db728d3a5fc357edd
|
7
|
+
data.tar.gz: 046e1c0509df6ee8ad09a35865515ada8927018881b333fe2698146aa561c0f5ff2e237a750eee1a0a08ef5550adb298907a64f34e44239d4750dafe178eab0b
|
data/ChangeLog
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
simple_cacheable (1.
|
4
|
+
simple_cacheable (1.4.0)
|
5
5
|
rails (>= 3.0.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -25,9 +25,9 @@ GEM
|
|
25
25
|
activesupport (= 4.0.0)
|
26
26
|
arel (~> 4.0.0)
|
27
27
|
activerecord-deprecated_finders (1.0.3)
|
28
|
-
activerecord-jdbc-adapter (1.2.
|
29
|
-
activerecord-jdbcsqlite3-adapter (1.2.
|
30
|
-
activerecord-jdbc-adapter (~> 1.2.
|
28
|
+
activerecord-jdbc-adapter (1.2.9.1)
|
29
|
+
activerecord-jdbcsqlite3-adapter (1.2.9)
|
30
|
+
activerecord-jdbc-adapter (~> 1.2.9)
|
31
31
|
jdbc-sqlite3 (~> 3.7.2)
|
32
32
|
activesupport (4.0.0)
|
33
33
|
i18n (~> 0.6, >= 0.6.4)
|
@@ -43,12 +43,12 @@ GEM
|
|
43
43
|
erubis (2.7.0)
|
44
44
|
hike (1.2.3)
|
45
45
|
i18n (0.6.4)
|
46
|
-
jdbc-sqlite3 (3.7.2)
|
47
|
-
jruby-memcached (0.5.
|
46
|
+
jdbc-sqlite3 (3.7.2.1)
|
47
|
+
jruby-memcached (0.5.5)
|
48
48
|
mail (2.5.4)
|
49
49
|
mime-types (~> 1.16)
|
50
50
|
treetop (~> 1.4.8)
|
51
|
-
memcached (1.
|
51
|
+
memcached (1.6.1)
|
52
52
|
metaclass (0.0.1)
|
53
53
|
mime-types (1.23)
|
54
54
|
minitest (4.7.5)
|
@@ -92,7 +92,9 @@ GEM
|
|
92
92
|
sprockets (~> 2.8)
|
93
93
|
sqlite3 (1.3.7)
|
94
94
|
thor (0.18.1)
|
95
|
-
thread_safe (0.1.
|
95
|
+
thread_safe (0.1.2)
|
96
|
+
atomic
|
97
|
+
thread_safe (0.1.2-java)
|
96
98
|
atomic
|
97
99
|
tilt (1.4.1)
|
98
100
|
treetop (1.4.14)
|
@@ -109,7 +111,7 @@ DEPENDENCIES
|
|
109
111
|
activerecord-jdbcsqlite3-adapter
|
110
112
|
jruby-memcached
|
111
113
|
memcached
|
112
|
-
mocha
|
113
|
-
rspec
|
114
|
+
mocha (= 0.10.5)
|
115
|
+
rspec (= 2.8)
|
114
116
|
simple_cacheable!
|
115
117
|
sqlite3
|
data/cacheable.gemspec
CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.description = %q{a simple cache implementation based on activerecord}
|
14
14
|
|
15
15
|
s.add_dependency("rails", ">= 3.0.0")
|
16
|
-
s.add_development_dependency("rspec")
|
17
|
-
s.add_development_dependency("mocha")
|
16
|
+
s.add_development_dependency("rspec", "2.8")
|
17
|
+
s.add_development_dependency("mocha", "0.10.5")
|
18
18
|
|
19
19
|
s.files = `git ls-files`.split("\n")
|
20
20
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
@@ -34,10 +34,13 @@ module Cacheable
|
|
34
34
|
after_commit "expire_#{association_name}_cache".to_sym
|
35
35
|
|
36
36
|
define_method("expire_#{association_name}_cache") do
|
37
|
+
|
37
38
|
if respond_to? "expire_#{reverse_association.name}_cache".to_sym
|
38
|
-
send("cached_#{reverse_association.name}").
|
39
|
-
|
40
|
-
|
39
|
+
unless send("cached_#{reverse_association.name}").nil?
|
40
|
+
send("cached_#{reverse_association.name}").expire_association_cache(association_name)
|
41
|
+
end
|
42
|
+
elsif !send(reverse_association.name).nil?
|
43
|
+
if send(reverse_association.name).respond_to?(reverse_through_association.name) && !send(reverse_association.name).send(reverse_through_association.name).nil?
|
41
44
|
send(reverse_association.name).send(reverse_through_association.name).expire_association_cache(association_name)
|
42
45
|
end
|
43
46
|
end
|
@@ -55,10 +58,13 @@ module Cacheable
|
|
55
58
|
|
56
59
|
define_method "expire_#{association_name}_cache" do
|
57
60
|
if respond_to? "cached_#{reverse_association.name}".to_sym
|
58
|
-
#
|
59
|
-
|
60
|
-
|
61
|
+
unless send("cached_#{reverse_association.name}").nil?
|
62
|
+
# cached_viewable.expire_association_cache
|
63
|
+
send("cached_#{reverse_association.name}").expire_association_cache(association_name)
|
64
|
+
end
|
65
|
+
elsif !send("#{reverse_association.name}").nil?
|
61
66
|
send("#{reverse_association.name}").each do |assoc|
|
67
|
+
next if assoc.nil?
|
62
68
|
assoc.expire_association_cache(association_name)
|
63
69
|
end
|
64
70
|
end
|
@@ -74,8 +80,10 @@ module Cacheable
|
|
74
80
|
|
75
81
|
define_method "expire_#{association_name}_cache" do
|
76
82
|
if respond_to? "cached_#{reverse_association.name}".to_sym
|
77
|
-
send("cached_#{reverse_association.name}").
|
78
|
-
|
83
|
+
unless send("cached_#{reverse_association.name}").nil?
|
84
|
+
send("cached_#{reverse_association.name}").expire_association_cache(association_name)
|
85
|
+
end
|
86
|
+
elsif !send("#{reverse_association.name}").nil?
|
79
87
|
send("#{reverse_association.name}").expire_association_cache(association_name)
|
80
88
|
end
|
81
89
|
end
|
data/lib/cacheable/version.rb
CHANGED
data/lib/cacheable.rb
CHANGED
@@ -190,6 +190,28 @@ describe Cacheable do
|
|
190
190
|
user.save
|
191
191
|
end
|
192
192
|
|
193
|
+
context "with a user" do
|
194
|
+
it "should not hit expire_association_cache on save" do
|
195
|
+
account = Account.create
|
196
|
+
user = User.new
|
197
|
+
user.expects(:expire_association_cache)
|
198
|
+
account.stubs(:user).returns user
|
199
|
+
account.save
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
context "without a user" do
|
204
|
+
it "should not hit expire_association_cache on save" do
|
205
|
+
account = Account.create
|
206
|
+
obj = mock "object"
|
207
|
+
obj.stubs(:nil?).returns true
|
208
|
+
account.stubs(:user).returns obj
|
209
|
+
obj.expects(:expire_association_cache).never
|
210
|
+
account.expire_account_cache
|
211
|
+
end
|
212
|
+
|
213
|
+
end
|
214
|
+
|
193
215
|
end
|
194
216
|
|
195
217
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_cacheable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Huang
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-07-
|
12
|
+
date: 2013-07-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -29,30 +29,30 @@ dependencies:
|
|
29
29
|
name: rspec
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- - '
|
32
|
+
- - '='
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
34
|
+
version: '2.8'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- - '
|
39
|
+
- - '='
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
41
|
+
version: '2.8'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: mocha
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - '
|
46
|
+
- - '='
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version:
|
48
|
+
version: 0.10.5
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- - '
|
53
|
+
- - '='
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version:
|
55
|
+
version: 0.10.5
|
56
56
|
description: a simple cache implementation based on activerecord
|
57
57
|
email:
|
58
58
|
- flyerhzm@gmail.com
|