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 +4 -4
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/ci.yml +7 -4
- data/.github/workflows/release.yml +26 -0
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +55 -39
- data/identity_cache.gemspec +2 -1
- data/lib/identity_cache/mem_cache_store_cas.rb +8 -15
- data/lib/identity_cache/query_api.rb +13 -4
- data/lib/identity_cache/version.rb +1 -1
- metadata +33 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e7f8714a727af9c655659c133b31c7b5fbb43ca5e163bf5a18bfa6b55acbc74c
|
|
4
|
+
data.tar.gz: 6cb65683f29a68fde6727146daf1428af90f79fc8360b21dd51fcf291c681137
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a00c855035a60e4f270e8c8f56d460049d359ac5d306924fd9b3770a58b8892674bcb036d15f0e0ddd538ef716a4261ea5924cefe4db4e6013662f06b773f2e7
|
|
7
|
+
data.tar.gz: 51a03f9a496bb30a75dc28a97dd6d0f9b17ca7b72ba01f6d9047578fbe1cef8f85705a170482aa177008ed9f4b73e054467b6d5f701a542e787e974081816cba
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -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: '
|
|
25
|
+
ruby: '4.0'
|
|
23
26
|
gemfile: "Gemfile.latest-release"
|
|
24
27
|
rubocop: true
|
|
25
28
|
- name: 'Rails edge'
|
|
26
|
-
ruby: '
|
|
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@
|
|
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:
|
|
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.
|
|
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 (
|
|
19
|
-
activesupport (=
|
|
20
|
-
activerecord (
|
|
21
|
-
activemodel (=
|
|
22
|
-
activesupport (=
|
|
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 (
|
|
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.
|
|
38
|
-
base64 (0.
|
|
39
|
-
|
|
40
|
-
|
|
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.
|
|
43
|
-
connection_pool (2.
|
|
44
|
-
dalli (3.2.
|
|
45
|
-
|
|
46
|
-
|
|
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.
|
|
49
|
-
language_server-protocol (3.17.0.
|
|
50
|
-
logger (1.
|
|
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.
|
|
55
|
-
mocha (2.1
|
|
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.
|
|
59
|
-
parser (3.3.0
|
|
64
|
+
parallel (1.27.0)
|
|
65
|
+
parser (3.3.9.0)
|
|
60
66
|
ast (~> 2.4.1)
|
|
61
67
|
racc
|
|
62
|
-
pg (1.5.
|
|
63
|
-
|
|
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.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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.
|
|
81
|
-
parser (>= 3.3.
|
|
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.
|
|
100
|
+
securerandom (0.4.1)
|
|
87
101
|
spy (1.0.5)
|
|
88
|
-
stackprof (0.2.
|
|
89
|
-
|
|
90
|
-
timeout (0.4.
|
|
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.
|
|
108
|
+
unicode-display_width (2.6.0)
|
|
109
|
+
uri (1.0.4)
|
|
94
110
|
|
|
95
111
|
PLATFORMS
|
|
96
|
-
arm64-darwin
|
|
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)
|
data/identity_cache.gemspec
CHANGED
|
@@ -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,
|
|
17
|
+
entry = deserialize_entry(raw_value, **options)
|
|
16
18
|
value = yield entry.value
|
|
17
|
-
entry =
|
|
18
|
-
|
|
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,
|
|
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 =
|
|
47
|
-
payload =
|
|
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
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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,
|
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.
|
|
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:
|
|
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.
|
|
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
|