second_level_cache 2.4.2 → 2.4.3
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/README.md +5 -3
- data/lib/second_level_cache/mixin.rb +10 -6
- data/lib/second_level_cache/version.rb +1 -1
- data/test/model/animal.rb +3 -0
- data/test/single_table_inheritance_test.rb +7 -0
- metadata +20 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ff0808eae35d2e443ca1160f93eaa9f23f9b1267e4338d3d89fca45715d0fbf
|
4
|
+
data.tar.gz: 1daad06b799d5506b2dff7cb23c898af371612cb38cc8963d24ea9276c66b30b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 564bd8a1dfeebb096450334bca5c077df923ffc6120e72d025188c1d47b8a705e003ff24f0698b59b0b60d32c877a90cb158286299c0683142bbe6612b31416d
|
7
|
+
data.tar.gz: efaf40b630af426f52538468c96b6d7ea24e14ed4137c3fedccadcc8de7c2c9c82c86b6ccf48d98a7c712e8d470ad997cb902199412f517ed5ebfa0187538cbe
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -170,12 +170,14 @@ Answer Load (0.2ms) SELECT `answers`.* FROM `answers` ORDER BY id DESC LIMIT 10
|
|
170
170
|
|
171
171
|
[Details for read_multi feature](http://hooopo.writings.io/articles/a9cae5e0).
|
172
172
|
|
173
|
-
##
|
173
|
+
## Original design by:
|
174
174
|
|
175
175
|
* [chloerei](https://github.com/chloerei)
|
176
|
-
* [reyesyang](https://github.com/reyesyang)
|
177
176
|
* [hooopo](https://github.com/hooopo)
|
178
|
-
|
177
|
+
|
178
|
+
## Contributors
|
179
|
+
|
180
|
+
[Contributor List](https://github.com/hooopo/second_level_cache/graphs/contributors)
|
179
181
|
|
180
182
|
## License
|
181
183
|
|
@@ -62,18 +62,22 @@ module SecondLevelCache
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def second_level_cache_key
|
65
|
-
|
65
|
+
klass.second_level_cache_key(id)
|
66
|
+
end
|
67
|
+
|
68
|
+
def klass
|
69
|
+
self.class.base_class
|
66
70
|
end
|
67
71
|
|
68
72
|
def expire_second_level_cache
|
69
|
-
return unless
|
73
|
+
return unless klass.second_level_cache_enabled?
|
70
74
|
SecondLevelCache.cache_store.delete(second_level_cache_key)
|
71
75
|
end
|
72
76
|
|
73
77
|
def write_second_level_cache
|
74
|
-
return unless
|
78
|
+
return unless klass.second_level_cache_enabled?
|
75
79
|
marshal = RecordMarshal.dump(self)
|
76
|
-
expires_in =
|
80
|
+
expires_in = klass.second_level_cache_options[:expires_in]
|
77
81
|
expire_changed_association_uniq_keys
|
78
82
|
SecondLevelCache.cache_store.write(second_level_cache_key, marshal, expires_in: expires_in)
|
79
83
|
end
|
@@ -81,10 +85,10 @@ module SecondLevelCache
|
|
81
85
|
alias update_second_level_cache write_second_level_cache
|
82
86
|
|
83
87
|
def expire_changed_association_uniq_keys
|
84
|
-
reflections =
|
88
|
+
reflections = klass.reflections.select { |_, reflection| reflection.belongs_to? }
|
85
89
|
changed_keys = reflections.map { |_, reflection| reflection.foreign_key } & previous_changes.keys
|
86
90
|
changed_keys.each do |key|
|
87
|
-
SecondLevelCache.cache_store.delete(
|
91
|
+
SecondLevelCache.cache_store.delete(klass.send(:cache_uniq_key, key => previous_changes[key][0]))
|
88
92
|
end
|
89
93
|
end
|
90
94
|
end
|
data/test/model/animal.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: second_level_cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hooopo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -192,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
192
192
|
version: '0'
|
193
193
|
requirements: []
|
194
194
|
rubyforge_project:
|
195
|
-
rubygems_version: 2.7.
|
195
|
+
rubygems_version: 2.7.6
|
196
196
|
signing_key:
|
197
197
|
specification_version: 4
|
198
198
|
summary: 'SecondLevelCache is a write-through and read-through caching library inspired
|
@@ -202,28 +202,28 @@ summary: 'SecondLevelCache is a write-through and read-through caching library i
|
|
202
202
|
is a cache miss, it will populate the cache. Write-Through: As objects are created,
|
203
203
|
updated, and deleted, all of the caches are automatically kept up-to-date and coherent.'
|
204
204
|
test_files:
|
205
|
-
- test/
|
206
|
-
- test/
|
205
|
+
- test/polymorphic_association_test.rb
|
206
|
+
- test/require_test.rb
|
207
|
+
- test/preloader_test.rb
|
208
|
+
- test/finder_methods_test.rb
|
209
|
+
- test/preloader_non_integer_test.rb
|
207
210
|
- test/belongs_to_association_test.rb
|
211
|
+
- test/second_level_cache_test.rb
|
208
212
|
- test/enum_attr_test.rb
|
209
|
-
- test/
|
210
|
-
- test/
|
211
|
-
- test/
|
213
|
+
- test/record_marshal_test.rb
|
214
|
+
- test/persistence_test.rb
|
215
|
+
- test/single_table_inheritance_test.rb
|
216
|
+
- test/model/image.rb
|
212
217
|
- test/model/account.rb
|
213
|
-
- test/model/
|
218
|
+
- test/model/order_item.rb
|
214
219
|
- test/model/book.rb
|
215
|
-
- test/model/
|
220
|
+
- test/model/topic.rb
|
221
|
+
- test/model/animal.rb
|
216
222
|
- test/model/order.rb
|
217
|
-
- test/model/order_item.rb
|
218
223
|
- test/model/post.rb
|
219
|
-
- test/model/topic.rb
|
220
224
|
- test/model/user.rb
|
221
|
-
- test/
|
222
|
-
- test/polymorphic_association_test.rb
|
223
|
-
- test/preloader_non_integer_test.rb
|
224
|
-
- test/preloader_test.rb
|
225
|
-
- test/record_marshal_test.rb
|
226
|
-
- test/require_test.rb
|
227
|
-
- test/second_level_cache_test.rb
|
228
|
-
- test/single_table_inheritance_test.rb
|
225
|
+
- test/fetch_by_uniq_key_test.rb
|
229
226
|
- test/test_helper.rb
|
227
|
+
- test/has_one_association_test.rb
|
228
|
+
- test/base_test.rb
|
229
|
+
- test/active_record_test_case_helper.rb
|