identity_cache 1.5.6 → 1.6.0
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 +4 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +7 -4
- data/lib/identity_cache/parent_model_expiration.rb +4 -0
- data/lib/identity_cache/version.rb +1 -1
- data/lib/identity_cache.rb +40 -0
- data/shipit.rubygems.yml +4 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0238eadfff3efbdc9ad2e6625ce51fa8bc43cf722f317ab096cf4dcf42b8ab11'
|
4
|
+
data.tar.gz: 8f6c334a2bcc97cceef427cb626dfd5cdd7528982a1062356113217e9268f836
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30132bc792a1095e821ddd2602cf6a7edead2f52a50f4a6d1fa75ab22321d4459172aa6de95760693ad069895d741b4756fc5b827581eea4d23b6beb813b7c21
|
7
|
+
data.tar.gz: b93b51adc8d89c33eb5e051f98e9f6637bd16e9c0fa4640a4b23bdea241548a428d3ea5dcc582922166d04096479bf1a62e27ba587029d2428e47bc9dacfea1f
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
@@ -11,7 +11,7 @@ gem "mysql2", "~> 0.5.3", platform: :mri
|
|
11
11
|
gem "pg", ">= 0.18", "< 2.0", platform: :mri
|
12
12
|
gem "memcached", "~> 1.8.0", platform: :mri
|
13
13
|
gem "memcached_store", "~> 2.3.2", platform: :mri
|
14
|
-
gem "dalli", "~> 2.
|
14
|
+
gem "dalli", "~> 3.2.3"
|
15
15
|
gem "cityhash", "~> 0.6.0", platform: :mri
|
16
16
|
|
17
17
|
gem "byebug", platform: :mri
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
identity_cache (1.
|
4
|
+
identity_cache (1.6.0)
|
5
5
|
activerecord (>= 7.0)
|
6
6
|
ar_transaction_changes (~> 1.1)
|
7
7
|
|
@@ -33,7 +33,7 @@ GEM
|
|
33
33
|
cityhash (0.6.0)
|
34
34
|
concurrent-ruby (1.2.3)
|
35
35
|
connection_pool (2.4.1)
|
36
|
-
dalli (2.
|
36
|
+
dalli (3.2.3)
|
37
37
|
drb (2.2.1)
|
38
38
|
i18n (1.14.4)
|
39
39
|
concurrent-ruby (~> 1.0)
|
@@ -57,7 +57,8 @@ GEM
|
|
57
57
|
rainbow (3.1.1)
|
58
58
|
rake (13.1.0)
|
59
59
|
regexp_parser (2.9.0)
|
60
|
-
rexml (3.2.
|
60
|
+
rexml (3.2.8)
|
61
|
+
strscan (>= 3.0.9)
|
61
62
|
rubocop (1.61.0)
|
62
63
|
json (~> 2.3)
|
63
64
|
language_server-protocol (>= 3.17.0)
|
@@ -77,6 +78,7 @@ GEM
|
|
77
78
|
ruby2_keywords (0.0.5)
|
78
79
|
spy (1.0.5)
|
79
80
|
stackprof (0.2.26)
|
81
|
+
strscan (3.1.0)
|
80
82
|
timeout (0.4.1)
|
81
83
|
tzinfo (2.0.6)
|
82
84
|
concurrent-ruby (~> 1.0)
|
@@ -84,12 +86,13 @@ GEM
|
|
84
86
|
|
85
87
|
PLATFORMS
|
86
88
|
arm64-darwin-22
|
89
|
+
arm64-darwin-23
|
87
90
|
x86_64-linux
|
88
91
|
|
89
92
|
DEPENDENCIES
|
90
93
|
byebug
|
91
94
|
cityhash (~> 0.6.0)
|
92
|
-
dalli (~> 2.
|
95
|
+
dalli (~> 3.2.3)
|
93
96
|
identity_cache!
|
94
97
|
memcached (~> 1.8.0)
|
95
98
|
memcached_store (~> 2.3.2)
|
@@ -47,6 +47,10 @@ module IdentityCache
|
|
47
47
|
add_parents_to_cache_expiry_set(parents_to_expire)
|
48
48
|
parents_to_expire.select! { |parent| parent.class.primary_cache_index_enabled }
|
49
49
|
parents_to_expire.reduce(true) do |all_expired, parent|
|
50
|
+
if Thread.current[:idc_deferred_parent_expiration]
|
51
|
+
Thread.current[:idc_parent_records_for_cache_expiry] << parent
|
52
|
+
next parent
|
53
|
+
end
|
50
54
|
parent.expire_primary_index && all_expired
|
51
55
|
end
|
52
56
|
end
|
data/lib/identity_cache.rb
CHANGED
@@ -60,6 +60,8 @@ module IdentityCache
|
|
60
60
|
|
61
61
|
class InverseAssociationError < StandardError; end
|
62
62
|
|
63
|
+
class NestedDeferredParentBlockError < StandardError; end
|
64
|
+
|
63
65
|
class UnsupportedScopeError < StandardError; end
|
64
66
|
|
65
67
|
class UnsupportedAssociationError < StandardError; end
|
@@ -191,6 +193,44 @@ module IdentityCache
|
|
191
193
|
result
|
192
194
|
end
|
193
195
|
|
196
|
+
# Executes a block with deferred parent expiration, ensuring that the parent
|
197
|
+
# records' cache expiration is deferred until the block completes. When the block
|
198
|
+
# completes, it triggers expiration of the primary index for the parent records.
|
199
|
+
# Raises a NestedDeferredParentBlockError if a deferred parent expiration block
|
200
|
+
# is already active on the current thread.
|
201
|
+
#
|
202
|
+
# == Parameters:
|
203
|
+
# No parameters.
|
204
|
+
#
|
205
|
+
# == Raises:
|
206
|
+
# NestedDeferredParentBlockError if a deferred parent expiration block is already active.
|
207
|
+
#
|
208
|
+
# == Yield:
|
209
|
+
# Runs the provided block with deferred parent expiration.
|
210
|
+
#
|
211
|
+
# == Returns:
|
212
|
+
# The result of executing the provided block.
|
213
|
+
#
|
214
|
+
# == Ensures:
|
215
|
+
# Cleans up thread-local variables related to deferred parent expiration regardless
|
216
|
+
# of whether the block raises an exception.
|
217
|
+
def with_deferred_parent_expiration
|
218
|
+
raise NestedDeferredParentBlockError if Thread.current[:idc_deferred_parent_expiration]
|
219
|
+
|
220
|
+
Thread.current[:idc_deferred_parent_expiration] = true
|
221
|
+
Thread.current[:idc_parent_records_for_cache_expiry] = Set.new
|
222
|
+
|
223
|
+
result = yield
|
224
|
+
|
225
|
+
Thread.current[:idc_deferred_parent_expiration] = nil
|
226
|
+
Thread.current[:idc_parent_records_for_cache_expiry].each(&:expire_primary_index)
|
227
|
+
|
228
|
+
result
|
229
|
+
ensure
|
230
|
+
Thread.current[:idc_deferred_parent_expiration] = nil
|
231
|
+
Thread.current[:idc_parent_records_for_cache_expiry].clear
|
232
|
+
end
|
233
|
+
|
194
234
|
def with_fetch_read_only_records(value = true)
|
195
235
|
old_value = Thread.current[:identity_cache_fetch_read_only_records]
|
196
236
|
Thread.current[:identity_cache_fetch_read_only_records] = value
|
data/shipit.rubygems.yml
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: identity_cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Camilo Lopez
|
@@ -11,10 +11,10 @@ authors:
|
|
11
11
|
- Tobias Lutke
|
12
12
|
- Arthur Neves
|
13
13
|
- Francis Bogsanyi
|
14
|
-
autorequire:
|
14
|
+
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
|
-
date: 2024-
|
17
|
+
date: 2024-07-05 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: activerecord
|
@@ -177,7 +177,7 @@ homepage: https://github.com/Shopify/identity_cache
|
|
177
177
|
licenses: []
|
178
178
|
metadata:
|
179
179
|
allowed_push_host: https://rubygems.org
|
180
|
-
post_install_message:
|
180
|
+
post_install_message:
|
181
181
|
rdoc_options: []
|
182
182
|
require_paths:
|
183
183
|
- lib
|
@@ -192,8 +192,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
192
192
|
- !ruby/object:Gem::Version
|
193
193
|
version: '0'
|
194
194
|
requirements: []
|
195
|
-
rubygems_version: 3.5.
|
196
|
-
signing_key:
|
195
|
+
rubygems_version: 3.5.14
|
196
|
+
signing_key:
|
197
197
|
specification_version: 4
|
198
198
|
summary: IdentityCache lets you specify how you want to cache your model objects,
|
199
199
|
at the model level, and adds a number of convenience methods for accessing those
|