identity_cache 1.6.3 → 1.6.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0daa9d36baa2b4c2e08dc8c29ab55274a1dbfab1d0146010720a68bfe9eff20e
4
- data.tar.gz: '08708fb388587b7def00967250321904ffbfa9c071aca71f6b360ea22ec0ab8f'
3
+ metadata.gz: e7f8714a727af9c655659c133b31c7b5fbb43ca5e163bf5a18bfa6b55acbc74c
4
+ data.tar.gz: 6cb65683f29a68fde6727146daf1428af90f79fc8360b21dd51fcf291c681137
5
5
  SHA512:
6
- metadata.gz: 61e4c7010330259878bb07f61a806b2b8d21d3cfbc67d07074cd9dddafd69471c6aa50ebdf880e39b9a0dba7203d0215f1336829842457ea877e3f065ce8e98e
7
- data.tar.gz: e1d0f10f2a4a3ff678b4b89b60547c342ab6a0ce8f5d1623ebcdb29c227e08ee7da8234c32ed3388b745aa11f4be1989d5a554a521152bdd72ebaa9c92cc9747
6
+ metadata.gz: a00c855035a60e4f270e8c8f56d460049d359ac5d306924fd9b3770a58b8892674bcb036d15f0e0ddd538ef716a4261ea5924cefe4db4e6013662f06b773f2e7
7
+ data.tar.gz: 51a03f9a496bb30a75dc28a97dd6d0f9b17ca7b72ba01f6d9047578fbe1cef8f85705a170482aa177008ed9f4b73e054467b6d5f701a542e787e974081816cba
@@ -0,0 +1,6 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: github-actions
4
+ directory: "/"
5
+ schedule:
6
+ interval: weekly
@@ -18,12 +18,15 @@ jobs:
18
18
  - name: 'Minimum supported'
19
19
  ruby: '3.0'
20
20
  gemfile: "Gemfile.min-supported"
21
+ - name: 'Latest Ruby 3'
22
+ ruby: '3.4'
23
+ gemfile: "Gemfile.latest-release"
21
24
  - name: 'Latest released & run rubocop'
22
- ruby: '3.3'
25
+ ruby: '4.0'
23
26
  gemfile: "Gemfile.latest-release"
24
27
  rubocop: true
25
28
  - name: 'Rails edge'
26
- ruby: '3.3'
29
+ ruby: '4.0'
27
30
  gemfile: "Gemfile.rails-edge"
28
31
  edge: true
29
32
 
@@ -70,9 +73,9 @@ jobs:
70
73
  sudo apt-get update
71
74
  sudo apt-get -y install libmemcached-dev libmysqlclient-dev libpq-dev libsasl2-dev
72
75
 
73
- - uses: actions/checkout@v2
76
+ - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
74
77
  - name: Set up Ruby
75
- uses: ruby/setup-ruby@v1
78
+ uses: ruby/setup-ruby@80740b3b13bf9857e28854481ca95a84e78a2bdf # v1.284.0
76
79
  with:
77
80
  ruby-version: ${{ matrix.entry.ruby }}
78
81
  bundler-cache: true
@@ -0,0 +1,26 @@
1
+ name: Release
2
+
3
+ on: workflow_dispatch
4
+
5
+ jobs:
6
+ release:
7
+ permissions:
8
+ contents: write
9
+ id-token: write
10
+
11
+ environment: release
12
+
13
+ runs-on: ubuntu-latest
14
+
15
+ steps:
16
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
17
+ - name: Install required packages
18
+ run: |
19
+ sudo apt-get update
20
+ sudo apt-get -y install libmemcached-dev libmysqlclient-dev libpq-dev libsasl2-dev
21
+ - name: Set up Ruby
22
+ uses: ruby/setup-ruby@95ef2b042f9d7a56d8268cba8559e2842e2ad01b # v1.321.0
23
+ with:
24
+ bundler-cache: true
25
+ ruby-version: 3.4
26
+ - uses: rubygems/release-gem@052cc82692552de3ef2b81fd670e41d13cba8092 # v1.4.0
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 1.6.5
6
+
7
+ - Improve MemCacheStoreCAS patch to properly pass serialized entries to Dalli.
8
+
9
+ ## 1.6.4
10
+
11
+ - Patch `run_callbacks` instead of `_run_commit_callbacks` to expire cache prior to `after_commit` callbacks. (#602)
12
+
5
13
  ## 1.6.3
6
14
 
7
15
  - Split the `with_deferred_parent_expiration` and `with_deferred_parent_expiration`. (#578)
data/Gemfile.lock CHANGED
@@ -1,6 +1,6 @@
1
1
  GIT
2
2
  remote: https://github.com/Shopify/memcached.git
3
- revision: 54a89bae698896a00fd2ceeb142dada6285f73ed
3
+ revision: 30f5735d5db2dfd50dd885ceeb51672320b356d3
4
4
  branch: 1-0-stable-shopify
5
5
  specs:
6
6
  memcached (1.9.0)
@@ -8,21 +8,23 @@ GIT
8
8
  PATH
9
9
  remote: .
10
10
  specs:
11
- identity_cache (1.6.3)
11
+ identity_cache (1.6.5)
12
12
  activerecord (>= 7.0)
13
13
  ar_transaction_changes (~> 1.1)
14
+ benchmark
14
15
 
15
16
  GEM
16
17
  remote: https://rubygems.org/
17
18
  specs:
18
- activemodel (7.2.0)
19
- activesupport (= 7.2.0)
20
- activerecord (7.2.0)
21
- activemodel (= 7.2.0)
22
- activesupport (= 7.2.0)
19
+ activemodel (8.0.2)
20
+ activesupport (= 8.0.2)
21
+ activerecord (8.0.2)
22
+ activemodel (= 8.0.2)
23
+ activesupport (= 8.0.2)
23
24
  timeout (>= 0.4.0)
24
- activesupport (7.2.0)
25
+ activesupport (8.0.2)
25
26
  base64
27
+ benchmark (>= 0.3)
26
28
  bigdecimal
27
29
  concurrent-ruby (~> 1.0, >= 1.3.1)
28
30
  connection_pool (>= 2.2.5)
@@ -32,40 +34,51 @@ GEM
32
34
  minitest (>= 5.1)
33
35
  securerandom (>= 0.3)
34
36
  tzinfo (~> 2.0, >= 2.0.5)
37
+ uri (>= 0.13.1)
35
38
  ar_transaction_changes (1.1.9)
36
39
  activerecord (>= 5.2.0)
37
- ast (2.4.2)
38
- base64 (0.2.0)
39
- bigdecimal (3.1.8)
40
- byebug (11.1.3)
40
+ ast (2.4.3)
41
+ base64 (0.3.0)
42
+ benchmark (0.4.1)
43
+ bigdecimal (3.2.2)
44
+ byebug (12.0.0)
41
45
  cityhash (0.6.0)
42
- concurrent-ruby (1.3.4)
43
- connection_pool (2.4.1)
44
- dalli (3.2.3)
45
- drb (2.2.1)
46
- i18n (1.14.5)
46
+ concurrent-ruby (1.3.5)
47
+ connection_pool (2.5.3)
48
+ dalli (3.2.8)
49
+ date (3.5.1)
50
+ drb (2.2.3)
51
+ erb (6.0.2)
52
+ i18n (1.14.7)
47
53
  concurrent-ruby (~> 1.0)
48
- json (2.7.1)
49
- language_server-protocol (3.17.0.3)
50
- logger (1.6.0)
54
+ json (2.13.1)
55
+ language_server-protocol (3.17.0.5)
56
+ logger (1.7.0)
51
57
  memcached_store (2.3.4)
52
58
  activesupport (>= 6)
53
59
  memcached (~> 1.8)
54
- minitest (5.25.1)
55
- mocha (2.1.0)
60
+ minitest (5.27.0)
61
+ mocha (2.7.1)
56
62
  ruby2_keywords (>= 0.0.5)
57
63
  mysql2 (0.5.6)
58
- parallel (1.24.0)
59
- parser (3.3.0.5)
64
+ parallel (1.27.0)
65
+ parser (3.3.9.0)
60
66
  ast (~> 2.4.1)
61
67
  racc
62
- pg (1.5.6)
63
- racc (1.7.3)
68
+ pg (1.5.9)
69
+ prism (1.4.0)
70
+ psych (5.3.1)
71
+ date
72
+ stringio
73
+ racc (1.8.1)
64
74
  rainbow (3.1.1)
65
- rake (13.1.0)
66
- regexp_parser (2.9.0)
67
- rexml (3.3.6)
68
- strscan
75
+ rake (13.3.0)
76
+ rdoc (7.2.0)
77
+ erb
78
+ psych (>= 4.0.0)
79
+ tsort
80
+ regexp_parser (2.10.0)
81
+ rexml (3.4.2)
69
82
  rubocop (1.61.0)
70
83
  json (~> 2.3)
71
84
  language_server-protocol (>= 3.17.0)
@@ -77,24 +90,26 @@ GEM
77
90
  rubocop-ast (>= 1.30.0, < 2.0)
78
91
  ruby-progressbar (~> 1.7)
79
92
  unicode-display_width (>= 2.4.0, < 3.0)
80
- rubocop-ast (1.31.2)
81
- parser (>= 3.3.0.4)
93
+ rubocop-ast (1.46.0)
94
+ parser (>= 3.3.7.2)
95
+ prism (~> 1.4)
82
96
  rubocop-shopify (2.9.0)
83
97
  rubocop (~> 1.33)
84
98
  ruby-progressbar (1.13.0)
85
99
  ruby2_keywords (0.0.5)
86
- securerandom (0.3.1)
100
+ securerandom (0.4.1)
87
101
  spy (1.0.5)
88
- stackprof (0.2.26)
89
- strscan (3.1.0)
90
- timeout (0.4.1)
102
+ stackprof (0.2.27)
103
+ stringio (3.2.0)
104
+ timeout (0.4.3)
105
+ tsort (0.2.0)
91
106
  tzinfo (2.0.6)
92
107
  concurrent-ruby (~> 1.0)
93
- unicode-display_width (2.5.0)
108
+ unicode-display_width (2.6.0)
109
+ uri (1.0.4)
94
110
 
95
111
  PLATFORMS
96
- arm64-darwin-22
97
- arm64-darwin-23
112
+ arm64-darwin
98
113
  x86_64-linux
99
114
 
100
115
  DEPENDENCIES
@@ -109,6 +124,7 @@ DEPENDENCIES
109
124
  mysql2 (~> 0.5.3)
110
125
  pg (>= 0.18, < 2.0)
111
126
  rake (~> 13.0)
127
+ rdoc
112
128
  rubocop (~> 1.61.0)
113
129
  rubocop-shopify (~> 2.9.0)
114
130
  spy (~> 1.0)
@@ -26,7 +26,6 @@ Gem::Specification.new do |gem|
26
26
  gem.files = Dir.chdir(File.expand_path(__dir__)) do
27
27
  %x(git ls-files -z).split("\x0").reject { |f| f.match(%r{^test/}) }
28
28
  end
29
- gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
30
29
  gem.name = "identity_cache"
31
30
  gem.require_paths = ["lib"]
32
31
  gem.version = IdentityCache::VERSION
@@ -37,9 +36,11 @@ Gem::Specification.new do |gem|
37
36
 
38
37
  gem.add_dependency("activerecord", ">= 7.0")
39
38
  gem.add_dependency("ar_transaction_changes", "~> 1.1")
39
+ gem.add_dependency("benchmark")
40
40
 
41
41
  gem.add_development_dependency("minitest", "~> 5.14")
42
42
  gem.add_development_dependency("mocha", "~> 2.0")
43
43
  gem.add_development_dependency("rake", "~> 13.0")
44
+ gem.add_development_dependency("rdoc")
44
45
  gem.add_development_dependency("spy", "~> 1.0")
45
46
  end
@@ -4,6 +4,8 @@ require "dalli/cas/client" unless Dalli::VERSION > "3"
4
4
 
5
5
  module IdentityCache
6
6
  module MemCacheStoreCAS
7
+ Entry = ActiveSupport::Cache::Entry
8
+
7
9
  def cas(name, options = nil)
8
10
  options = merged_options(options)
9
11
  key = normalize_key(name, options)
@@ -12,10 +14,10 @@ module IdentityCache
12
14
  instrument(:cas, key, options) do
13
15
  @data.with do |connection|
14
16
  connection.cas(key, options[:expires_in].to_i, options) do |raw_value|
15
- entry = deserialize_entry(raw_value, raw: options[:raw])
17
+ entry = deserialize_entry(raw_value, **options)
16
18
  value = yield entry.value
17
- entry = ActiveSupport::Cache::Entry.new(value, **options)
18
- options[:raw] ? entry.value.to_s : entry
19
+ entry = Entry.new(value, **options, version: normalize_version(name, options))
20
+ serialize_entry(entry, **options)
19
21
  end
20
22
  end
21
23
  end
@@ -34,7 +36,7 @@ module IdentityCache
34
36
 
35
37
  values = {}
36
38
  raw_values.each do |key, raw_value|
37
- entry = deserialize_entry(raw_value.first, raw: options[:raw])
39
+ entry = deserialize_entry(raw_value.first, **options)
38
40
  values[keys_to_names[key]] = entry.value unless entry.expired?
39
41
  end
40
42
 
@@ -43,21 +45,12 @@ module IdentityCache
43
45
  updates.each do |name, value|
44
46
  key = normalize_key(name, options)
45
47
  cas_id = raw_values[key].last
46
- entry = ActiveSupport::Cache::Entry.new(value, **options)
47
- payload = options[:raw] ? entry.value.to_s : entry
48
+ entry = Entry.new(value, **options)
49
+ payload = serialize_entry(entry, **options)
48
50
  @data.with { |c| c.replace_cas(key, payload, cas_id, options[:expires_in].to_i, options) }
49
51
  end
50
52
  end
51
53
  end
52
54
  end
53
-
54
- if ActiveSupport::Cache::MemCacheStore.instance_method(:deserialize_entry).arity == 1
55
-
56
- private
57
-
58
- def deserialize_entry(payload, raw: nil)
59
- super(payload)
60
- end
61
- end
62
55
  end
63
56
  end
@@ -165,11 +165,20 @@ module IdentityCache
165
165
  # cache reads that happen from the ordering of callbacks. For example, if an after_commit
166
166
  # callback enqueues a background job, then we don't want it to be possible for the
167
167
  # background job to run and load data from the cache before it is invalidated.
168
- def _run_commit_callbacks
169
- if destroyed? || transaction_changed_attributes.present?
170
- expire_cache
168
+ if ActiveRecord.version >= Gem::Version.new("7.1")
169
+ def run_callbacks(kind, type = nil)
170
+ if kind == :commit && (destroyed? || transaction_changed_attributes.present?)
171
+ expire_cache
172
+ end
173
+ super
174
+ end
175
+ else
176
+ def run_callbacks(kind)
177
+ if kind == :commit && (destroyed? || transaction_changed_attributes.present?)
178
+ expire_cache
179
+ end
180
+ super
171
181
  end
172
- super
173
182
  end
174
183
 
175
184
  # Invalidate the cache data associated with the record. Returns `true` on success,
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IdentityCache
4
- VERSION = "1.6.3"
4
+ VERSION = "1.6.5"
5
5
  CACHE_VERSION = 8
6
6
  end
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.6.3
4
+ version: 1.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Camilo Lopez
@@ -11,10 +11,9 @@ authors:
11
11
  - Tobias Lutke
12
12
  - Arthur Neves
13
13
  - Francis Bogsanyi
14
- autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
- date: 2024-10-22 00:00:00.000000000 Z
16
+ date: 1980-01-02 00:00:00.000000000 Z
18
17
  dependencies:
19
18
  - !ruby/object:Gem::Dependency
20
19
  name: activerecord
@@ -44,6 +43,20 @@ dependencies:
44
43
  - - "~>"
45
44
  - !ruby/object:Gem::Version
46
45
  version: '1.1'
46
+ - !ruby/object:Gem::Dependency
47
+ name: benchmark
48
+ requirement: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ type: :runtime
54
+ prerelease: false
55
+ version_requirements: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
47
60
  - !ruby/object:Gem::Dependency
48
61
  name: minitest
49
62
  requirement: !ruby/object:Gem::Requirement
@@ -86,6 +99,20 @@ dependencies:
86
99
  - - "~>"
87
100
  - !ruby/object:Gem::Version
88
101
  version: '13.0'
102
+ - !ruby/object:Gem::Dependency
103
+ name: rdoc
104
+ requirement: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ type: :development
110
+ prerelease: false
111
+ version_requirements: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
89
116
  - !ruby/object:Gem::Dependency
90
117
  name: spy
91
118
  requirement: !ruby/object:Gem::Requirement
@@ -107,8 +134,10 @@ executables: []
107
134
  extensions: []
108
135
  extra_rdoc_files: []
109
136
  files:
137
+ - ".github/dependabot.yml"
110
138
  - ".github/workflows/ci.yml"
111
139
  - ".github/workflows/cla.yml"
140
+ - ".github/workflows/release.yml"
112
141
  - ".gitignore"
113
142
  - ".rubocop.yml"
114
143
  - ".ruby-version"
@@ -176,7 +205,6 @@ homepage: https://github.com/Shopify/identity_cache
176
205
  licenses: []
177
206
  metadata:
178
207
  allowed_push_host: https://rubygems.org
179
- post_install_message:
180
208
  rdoc_options: []
181
209
  require_paths:
182
210
  - lib
@@ -191,8 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
219
  - !ruby/object:Gem::Version
192
220
  version: '0'
193
221
  requirements: []
194
- rubygems_version: 3.5.22
195
- signing_key:
222
+ rubygems_version: 3.6.9
196
223
  specification_version: 4
197
224
  summary: IdentityCache lets you specify how you want to cache your model objects,
198
225
  at the model level, and adds a number of convenience methods for accessing those