activesupport_cache_database 0.1.2 → 0.2.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/.github/workflows/ruby.yml +21 -0
- data/.rubocop.yml +12 -4
- data/Gemfile.lock +64 -44
- data/activesupport_cache_database.gemspec +3 -3
- data/spec/active_support/cache/database_store_spec.rb +54 -53
- data/spec/spec_helper.rb +1 -1
- metadata +6 -6
- data/.travis.yml +0 -15
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d60d7d422c325c71a260bc33eb80fa7b402cd467afbed925778820c1d27d51bb
|
|
4
|
+
data.tar.gz: cef45b1c8e48c971737b52ebe318b2e76f5ef0f846ac997155c4b5e0a3fdc533
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1637788764095dff7192fa782f2dcb62d14155d7a739bf00af1c60ea58798221f550e034f2035dbf827a0695545a6f1467b3bbfa0a7e85fcae0142e4e24b644f
|
|
7
|
+
data.tar.gz: 20429c7f45dc8fc0d3383c20992b5e0185522d106916a32225c5411ba6edab3b49ac4df78dc2e8b4f024e3c588156aa37b3e51cfce03c2a6ff01268f1d90ad3b
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
name: Ruby
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
ruby-version: ["2.6", "2.7", "3.0"]
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v2
|
|
17
|
+
- uses: ruby/setup-ruby@v1
|
|
18
|
+
with:
|
|
19
|
+
ruby-version: ${{ matrix.ruby-version }}
|
|
20
|
+
bundler-cache: true
|
|
21
|
+
- run: bundle exec rake
|
data/.rubocop.yml
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
-
|
|
3
|
-
|
|
1
|
+
inherit_gem:
|
|
2
|
+
rubocop-bsm:
|
|
3
|
+
- default.yml
|
|
4
|
+
inherit_mode:
|
|
5
|
+
merge:
|
|
6
|
+
- Exclude
|
|
4
7
|
AllCops:
|
|
5
|
-
TargetRubyVersion: "2.
|
|
8
|
+
TargetRubyVersion: "2.6"
|
|
9
|
+
|
|
6
10
|
Security/MarshalLoad:
|
|
7
11
|
Enabled: false
|
|
12
|
+
RSpec/SubjectStub:
|
|
13
|
+
Enabled: false
|
|
14
|
+
RSpec/MessageSpies:
|
|
15
|
+
Enabled: false
|
data/Gemfile.lock
CHANGED
|
@@ -1,68 +1,88 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
activesupport_cache_database (0.
|
|
4
|
+
activesupport_cache_database (0.2.0)
|
|
5
5
|
activerecord (>= 5.0)
|
|
6
6
|
activesupport (>= 5.0)
|
|
7
7
|
|
|
8
8
|
GEM
|
|
9
9
|
remote: https://rubygems.org/
|
|
10
10
|
specs:
|
|
11
|
-
activemodel (6.
|
|
12
|
-
activesupport (= 6.
|
|
13
|
-
activerecord (6.
|
|
14
|
-
activemodel (= 6.
|
|
15
|
-
activesupport (= 6.
|
|
16
|
-
activesupport (6.
|
|
11
|
+
activemodel (6.1.3)
|
|
12
|
+
activesupport (= 6.1.3)
|
|
13
|
+
activerecord (6.1.3)
|
|
14
|
+
activemodel (= 6.1.3)
|
|
15
|
+
activesupport (= 6.1.3)
|
|
16
|
+
activesupport (6.1.3)
|
|
17
17
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
18
|
-
i18n (>=
|
|
19
|
-
minitest (
|
|
20
|
-
tzinfo (~>
|
|
21
|
-
zeitwerk (~> 2.
|
|
22
|
-
ast (2.4.
|
|
23
|
-
concurrent-ruby (1.1.
|
|
24
|
-
diff-lcs (1.
|
|
25
|
-
i18n (1.8.
|
|
18
|
+
i18n (>= 1.6, < 2)
|
|
19
|
+
minitest (>= 5.1)
|
|
20
|
+
tzinfo (~> 2.0)
|
|
21
|
+
zeitwerk (~> 2.3)
|
|
22
|
+
ast (2.4.2)
|
|
23
|
+
concurrent-ruby (1.1.8)
|
|
24
|
+
diff-lcs (1.4.4)
|
|
25
|
+
i18n (1.8.9)
|
|
26
26
|
concurrent-ruby (~> 1.0)
|
|
27
|
-
minitest (5.14.
|
|
27
|
+
minitest (5.14.4)
|
|
28
28
|
mysql2 (0.5.3)
|
|
29
|
-
parallel (1.
|
|
30
|
-
parser (
|
|
31
|
-
ast (~> 2.4.
|
|
29
|
+
parallel (1.20.1)
|
|
30
|
+
parser (3.0.0.0)
|
|
31
|
+
ast (~> 2.4.1)
|
|
32
32
|
pg (1.2.3)
|
|
33
|
+
rack (2.2.3)
|
|
33
34
|
rainbow (3.0.0)
|
|
34
|
-
rake (13.0.
|
|
35
|
+
rake (13.0.3)
|
|
36
|
+
regexp_parser (2.1.1)
|
|
35
37
|
rexml (3.2.4)
|
|
36
|
-
rspec (3.
|
|
37
|
-
rspec-core (~> 3.
|
|
38
|
-
rspec-expectations (~> 3.
|
|
39
|
-
rspec-mocks (~> 3.
|
|
40
|
-
rspec-core (3.
|
|
41
|
-
rspec-support (~> 3.
|
|
42
|
-
rspec-expectations (3.
|
|
38
|
+
rspec (3.10.0)
|
|
39
|
+
rspec-core (~> 3.10.0)
|
|
40
|
+
rspec-expectations (~> 3.10.0)
|
|
41
|
+
rspec-mocks (~> 3.10.0)
|
|
42
|
+
rspec-core (3.10.1)
|
|
43
|
+
rspec-support (~> 3.10.0)
|
|
44
|
+
rspec-expectations (3.10.1)
|
|
43
45
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
44
|
-
rspec-support (~> 3.
|
|
45
|
-
rspec-mocks (3.
|
|
46
|
+
rspec-support (~> 3.10.0)
|
|
47
|
+
rspec-mocks (3.10.2)
|
|
46
48
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
47
|
-
rspec-support (~> 3.
|
|
48
|
-
rspec-support (3.
|
|
49
|
-
rubocop (
|
|
49
|
+
rspec-support (~> 3.10.0)
|
|
50
|
+
rspec-support (3.10.2)
|
|
51
|
+
rubocop (1.11.0)
|
|
50
52
|
parallel (~> 1.10)
|
|
51
|
-
parser (>=
|
|
53
|
+
parser (>= 3.0.0.0)
|
|
52
54
|
rainbow (>= 2.2.2, < 4.0)
|
|
55
|
+
regexp_parser (>= 1.8, < 3.0)
|
|
53
56
|
rexml
|
|
54
|
-
rubocop-ast (>= 0.0
|
|
57
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
|
55
58
|
ruby-progressbar (~> 1.7)
|
|
56
|
-
unicode-display_width (>= 1.4.0, <
|
|
57
|
-
rubocop-ast (
|
|
58
|
-
parser (>= 2.7.
|
|
59
|
-
|
|
59
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
|
60
|
+
rubocop-ast (1.4.1)
|
|
61
|
+
parser (>= 2.7.1.5)
|
|
62
|
+
rubocop-bsm (0.5.4)
|
|
63
|
+
rubocop (~> 1.0)
|
|
64
|
+
rubocop-performance
|
|
65
|
+
rubocop-rails
|
|
66
|
+
rubocop-rake
|
|
67
|
+
rubocop-rspec
|
|
68
|
+
rubocop-performance (1.10.1)
|
|
69
|
+
rubocop (>= 0.90.0, < 2.0)
|
|
70
|
+
rubocop-ast (>= 0.4.0)
|
|
71
|
+
rubocop-rails (2.9.1)
|
|
72
|
+
activesupport (>= 4.2.0)
|
|
73
|
+
rack (>= 1.1)
|
|
74
|
+
rubocop (>= 0.90.0, < 2.0)
|
|
75
|
+
rubocop-rake (0.5.1)
|
|
76
|
+
rubocop
|
|
77
|
+
rubocop-rspec (2.2.0)
|
|
78
|
+
rubocop (~> 1.0)
|
|
79
|
+
rubocop-ast (>= 1.1.0)
|
|
80
|
+
ruby-progressbar (1.11.0)
|
|
60
81
|
sqlite3 (1.4.2)
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
zeitwerk (2.3.0)
|
|
82
|
+
tzinfo (2.0.4)
|
|
83
|
+
concurrent-ruby (~> 1.0)
|
|
84
|
+
unicode-display_width (2.0.0)
|
|
85
|
+
zeitwerk (2.4.2)
|
|
66
86
|
|
|
67
87
|
PLATFORMS
|
|
68
88
|
ruby
|
|
@@ -74,7 +94,7 @@ DEPENDENCIES
|
|
|
74
94
|
pg
|
|
75
95
|
rake
|
|
76
96
|
rspec
|
|
77
|
-
rubocop
|
|
97
|
+
rubocop-bsm
|
|
78
98
|
sqlite3
|
|
79
99
|
|
|
80
100
|
BUNDLED WITH
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Gem::Specification.new do |s|
|
|
2
2
|
s.name = 'activesupport_cache_database'
|
|
3
|
-
s.version = '0.
|
|
3
|
+
s.version = '0.2.0'
|
|
4
4
|
s.authors = ['Black Square Media Ltd']
|
|
5
5
|
s.email = ['info@blacksquaremedia.com']
|
|
6
6
|
s.summary = %(ActiveSupport::Cache::Store implementation backed by ActiveRecord.)
|
|
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
|
|
|
11
11
|
s.files = `git ls-files -z`.split("\x0").reject {|f| f.match(%r{^spec/}) }
|
|
12
12
|
s.test_files = `git ls-files -z -- spec/*`.split("\x0")
|
|
13
13
|
s.require_paths = ['lib']
|
|
14
|
-
s.required_ruby_version = '>= 2.
|
|
14
|
+
s.required_ruby_version = '>= 2.6'
|
|
15
15
|
|
|
16
16
|
s.add_dependency 'activerecord', '>= 5.0'
|
|
17
17
|
s.add_dependency 'activesupport', '>= 5.0'
|
|
@@ -21,6 +21,6 @@ Gem::Specification.new do |s|
|
|
|
21
21
|
s.add_development_dependency 'pg'
|
|
22
22
|
s.add_development_dependency 'rake'
|
|
23
23
|
s.add_development_dependency 'rspec'
|
|
24
|
-
s.add_development_dependency 'rubocop'
|
|
24
|
+
s.add_development_dependency 'rubocop-bsm'
|
|
25
25
|
s.add_development_dependency 'sqlite3'
|
|
26
26
|
end
|
|
@@ -5,56 +5,56 @@ RSpec.describe ActiveSupport::Cache::DatabaseStore do
|
|
|
5
5
|
described_class.new expires_in: 60
|
|
6
6
|
end
|
|
7
7
|
|
|
8
|
-
it '
|
|
8
|
+
it 'reads and write strings' do
|
|
9
9
|
expect(subject.write('foo', 'bar')).to be_truthy
|
|
10
10
|
expect(subject.read('foo')).to eq('bar')
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
it '
|
|
13
|
+
it 'reads and write hash' do
|
|
14
14
|
expect(subject.write('foo', a: 'b')).to be_truthy
|
|
15
15
|
expect(subject.read('foo')).to eq(a: 'b')
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
it '
|
|
18
|
+
it 'reads and write integer' do
|
|
19
19
|
expect(subject.write('foo', 1)).to be_truthy
|
|
20
20
|
expect(subject.read('foo')).to eq(1)
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
it '
|
|
23
|
+
it 'reads and write nil' do
|
|
24
24
|
expect(subject.write('foo', nil)).to be_truthy
|
|
25
25
|
expect(subject.read('foo')).to eq(nil)
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
it '
|
|
28
|
+
it 'reads and write false' do
|
|
29
29
|
expect(subject.write('foo', false)).to be_truthy
|
|
30
30
|
expect(subject.read('foo')).to eq(false)
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
it '
|
|
33
|
+
it 'overwrites' do
|
|
34
34
|
expect(subject.write('foo', 'bar')).to be_truthy
|
|
35
35
|
expect(subject.write('foo', 'baz')).to be_truthy
|
|
36
36
|
expect(subject.read('foo')).to eq('baz')
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
-
it '
|
|
39
|
+
it 'supports exist?' do
|
|
40
40
|
subject.write('foo', 'bar')
|
|
41
|
-
expect(subject.exist
|
|
42
|
-
expect(subject.exist
|
|
41
|
+
expect(subject).to exist('foo')
|
|
42
|
+
expect(subject).not_to exist('bar')
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
-
it '
|
|
45
|
+
it 'supports nil exist?' do
|
|
46
46
|
subject.write('foo', nil)
|
|
47
|
-
expect(subject.exist
|
|
47
|
+
expect(subject).to exist('foo')
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
-
it '
|
|
50
|
+
it 'supports delete' do
|
|
51
51
|
subject.write('foo', 'bar')
|
|
52
|
-
expect(subject.exist
|
|
52
|
+
expect(subject).to exist('foo')
|
|
53
53
|
expect(subject.delete('foo')).to be_truthy
|
|
54
|
-
expect(subject.exist
|
|
54
|
+
expect(subject).not_to exist('foo')
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
-
it '
|
|
57
|
+
it 'supports expires_in' do
|
|
58
58
|
time = Time.local(2008, 4, 24)
|
|
59
59
|
allow(Time).to receive(:now).and_return(time)
|
|
60
60
|
|
|
@@ -68,7 +68,7 @@ RSpec.describe ActiveSupport::Cache::DatabaseStore do
|
|
|
68
68
|
expect(subject.read('foo')).to be_nil
|
|
69
69
|
end
|
|
70
70
|
|
|
71
|
-
it '
|
|
71
|
+
it 'supports long keys' do
|
|
72
72
|
key = 'x' * 255
|
|
73
73
|
expect(subject.write(key, 'bar')).to be_truthy
|
|
74
74
|
expect(subject.read(key)).to eq('bar')
|
|
@@ -82,7 +82,7 @@ RSpec.describe ActiveSupport::Cache::DatabaseStore do
|
|
|
82
82
|
end
|
|
83
83
|
|
|
84
84
|
describe '#cleanup' do
|
|
85
|
-
it '
|
|
85
|
+
it 'deletes expired' do
|
|
86
86
|
time = Time.now
|
|
87
87
|
subject.write('foo', 'bar', expires_in: 10)
|
|
88
88
|
subject.write('fud', 'biz', expires_in: 20)
|
|
@@ -96,7 +96,7 @@ RSpec.describe ActiveSupport::Cache::DatabaseStore do
|
|
|
96
96
|
expect(subject.read('fud')).to eq('biz')
|
|
97
97
|
end
|
|
98
98
|
|
|
99
|
-
it '
|
|
99
|
+
it 'supports namespace' do
|
|
100
100
|
time = Time.now
|
|
101
101
|
subject.write('foo', 'bar', expires_in: 10, namespace: 'x')
|
|
102
102
|
subject.write('foo', 'biz', expires_in: 10, namespace: 'y')
|
|
@@ -112,7 +112,7 @@ RSpec.describe ActiveSupport::Cache::DatabaseStore do
|
|
|
112
112
|
end
|
|
113
113
|
|
|
114
114
|
describe '#clear' do
|
|
115
|
-
it '
|
|
115
|
+
it 'removes all entries' do
|
|
116
116
|
subject.write('foo', 'bar')
|
|
117
117
|
subject.write('fud', 'biz')
|
|
118
118
|
expect(subject.clear).to be_truthy
|
|
@@ -120,7 +120,7 @@ RSpec.describe ActiveSupport::Cache::DatabaseStore do
|
|
|
120
120
|
expect(subject.read('fud')).to be_nil
|
|
121
121
|
end
|
|
122
122
|
|
|
123
|
-
it '
|
|
123
|
+
it 'supports namespace' do
|
|
124
124
|
subject.write('foo', 'bar', namespace: 'x')
|
|
125
125
|
subject.write('foo', 'biz', namespace: 'y')
|
|
126
126
|
expect(subject.count).to eq(2)
|
|
@@ -131,19 +131,19 @@ RSpec.describe ActiveSupport::Cache::DatabaseStore do
|
|
|
131
131
|
end
|
|
132
132
|
|
|
133
133
|
describe '#fetch' do
|
|
134
|
-
it '
|
|
134
|
+
it 'supports cache hit' do
|
|
135
135
|
subject.write('foo', 'bar')
|
|
136
136
|
expect(subject).not_to receive(:write)
|
|
137
137
|
|
|
138
138
|
expect(subject.fetch('foo') { 'baz' }).to eq('bar')
|
|
139
139
|
end
|
|
140
140
|
|
|
141
|
-
it '
|
|
141
|
+
it 'supports cache miss' do
|
|
142
142
|
expect(subject).to receive(:write).with('foo', 'baz', instance_of(Hash))
|
|
143
143
|
expect(subject.fetch('foo') { 'baz' }).to eq('baz')
|
|
144
144
|
end
|
|
145
145
|
|
|
146
|
-
it '
|
|
146
|
+
it 'passes key to block on cache miss' do
|
|
147
147
|
cache_miss = false
|
|
148
148
|
expect(subject.fetch('foo') {|key| cache_miss = true; key.length }).to eq(3)
|
|
149
149
|
expect(cache_miss).to be_truthy
|
|
@@ -153,32 +153,32 @@ RSpec.describe ActiveSupport::Cache::DatabaseStore do
|
|
|
153
153
|
expect(cache_miss).to be_falsey
|
|
154
154
|
end
|
|
155
155
|
|
|
156
|
-
it '
|
|
156
|
+
it 'supports forced cache miss' do
|
|
157
157
|
subject.write('foo', 'bar')
|
|
158
158
|
expect(subject).not_to receive(:read)
|
|
159
159
|
|
|
160
160
|
expect(subject.fetch('foo', force: true) { 'baz' }).to eq('baz')
|
|
161
161
|
end
|
|
162
162
|
|
|
163
|
-
it '
|
|
163
|
+
it 'supports nil values' do
|
|
164
164
|
subject.write('foo', nil)
|
|
165
165
|
expect(subject).not_to receive(:write)
|
|
166
166
|
|
|
167
167
|
expect(subject.fetch('foo') { 'baz' }).to be_nil
|
|
168
168
|
end
|
|
169
169
|
|
|
170
|
-
it '
|
|
170
|
+
it 'supports skip_nil option' do
|
|
171
171
|
expect(subject).not_to receive(:write)
|
|
172
172
|
expect(subject.fetch('foo', skip_nil: true) { nil }).to be_nil
|
|
173
|
-
expect(subject.exist
|
|
173
|
+
expect(subject).not_to exist('foo')
|
|
174
174
|
end
|
|
175
175
|
|
|
176
|
-
it '
|
|
176
|
+
it 'supports forced cache miss with block' do
|
|
177
177
|
subject.write('foo', 'bar')
|
|
178
178
|
expect(subject.fetch('foo', force: true) { 'baz' }).to eq('baz')
|
|
179
179
|
end
|
|
180
180
|
|
|
181
|
-
it '
|
|
181
|
+
it 'supports forced cache miss without block' do
|
|
182
182
|
subject.write('foo', 'bar')
|
|
183
183
|
expect { subject.fetch('foo', force: true) }.to raise_error(ArgumentError)
|
|
184
184
|
expect(subject.read('foo')).to eq('bar')
|
|
@@ -186,14 +186,14 @@ RSpec.describe ActiveSupport::Cache::DatabaseStore do
|
|
|
186
186
|
end
|
|
187
187
|
|
|
188
188
|
describe '#read_multi' do
|
|
189
|
-
it '
|
|
189
|
+
it 'supports read_multi' do
|
|
190
190
|
subject.write('foo', 'bar')
|
|
191
191
|
subject.write('fu', 'baz')
|
|
192
192
|
subject.write('fud', 'biz')
|
|
193
193
|
expect(subject.read_multi('foo', 'fu')).to eq('foo' => 'bar', 'fu' => 'baz')
|
|
194
194
|
end
|
|
195
195
|
|
|
196
|
-
it '
|
|
196
|
+
it 'supports expires' do
|
|
197
197
|
time = Time.now
|
|
198
198
|
subject.write('foo', 'bar', expires_in: 10)
|
|
199
199
|
subject.write('fu', 'baz')
|
|
@@ -205,7 +205,7 @@ RSpec.describe ActiveSupport::Cache::DatabaseStore do
|
|
|
205
205
|
end
|
|
206
206
|
|
|
207
207
|
describe '#fetch_multi' do
|
|
208
|
-
it '
|
|
208
|
+
it 'supports fetch_multi' do
|
|
209
209
|
subject.write('foo', 'bar')
|
|
210
210
|
subject.write('fud', 'biz')
|
|
211
211
|
values = subject.fetch_multi('foo', 'fu', 'fud') {|v| v * 2 }
|
|
@@ -214,7 +214,7 @@ RSpec.describe ActiveSupport::Cache::DatabaseStore do
|
|
|
214
214
|
expect(subject.read('fu')).to eq('fufu')
|
|
215
215
|
end
|
|
216
216
|
|
|
217
|
-
it '
|
|
217
|
+
it 'supports without expires_in' do
|
|
218
218
|
subject.write('foo', 'bar')
|
|
219
219
|
subject.write('fud', 'biz')
|
|
220
220
|
values = subject.fetch_multi('foo', 'fu', 'fud', expires_in: nil) {|v| v * 2 }
|
|
@@ -223,7 +223,7 @@ RSpec.describe ActiveSupport::Cache::DatabaseStore do
|
|
|
223
223
|
expect(subject.read('fu')).to eq('fufu')
|
|
224
224
|
end
|
|
225
225
|
|
|
226
|
-
it '
|
|
226
|
+
it 'supports with objects' do
|
|
227
227
|
cache_struct = Struct.new(:cache_key, :title)
|
|
228
228
|
foo = cache_struct.new('foo', 'FOO!')
|
|
229
229
|
bar = cache_struct.new('bar')
|
|
@@ -233,19 +233,19 @@ RSpec.describe ActiveSupport::Cache::DatabaseStore do
|
|
|
233
233
|
expect(values).to eq(foo => 'FOO!', bar => 'BAM!')
|
|
234
234
|
end
|
|
235
235
|
|
|
236
|
-
it '
|
|
236
|
+
it 'supports ordered names' do
|
|
237
237
|
subject.write('bam', 'BAM')
|
|
238
238
|
values = subject.fetch_multi('foo', 'bar', 'bam', &:upcase)
|
|
239
239
|
expect(values.keys).to eq(%w[foo bar bam])
|
|
240
240
|
end
|
|
241
241
|
|
|
242
|
-
it '
|
|
242
|
+
it 'raises without block' do
|
|
243
243
|
expect { subject.fetch_multi('foo') }.to raise_error(ArgumentError)
|
|
244
244
|
end
|
|
245
245
|
end
|
|
246
246
|
|
|
247
247
|
describe 'cache key' do
|
|
248
|
-
it '
|
|
248
|
+
it 'supports cache keys' do
|
|
249
249
|
obj = Object.new
|
|
250
250
|
def obj.cache_key
|
|
251
251
|
:foo
|
|
@@ -254,16 +254,17 @@ RSpec.describe ActiveSupport::Cache::DatabaseStore do
|
|
|
254
254
|
expect(subject.read('foo')).to eq('bar')
|
|
255
255
|
end
|
|
256
256
|
|
|
257
|
-
it '
|
|
258
|
-
obj =
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
257
|
+
it 'supports to_param keys' do
|
|
258
|
+
obj = Class.new do
|
|
259
|
+
def to_param
|
|
260
|
+
'foo'
|
|
261
|
+
end
|
|
262
|
+
end.new
|
|
262
263
|
subject.write(obj, 'bar')
|
|
263
264
|
expect(subject.read('foo')).to eq('bar')
|
|
264
265
|
end
|
|
265
266
|
|
|
266
|
-
it '
|
|
267
|
+
it 'supports unversioned keys' do
|
|
267
268
|
obj = Object.new
|
|
268
269
|
def obj.cache_key
|
|
269
270
|
:foo
|
|
@@ -276,42 +277,42 @@ RSpec.describe ActiveSupport::Cache::DatabaseStore do
|
|
|
276
277
|
expect(subject.read('foo')).to eq('bar')
|
|
277
278
|
end
|
|
278
279
|
|
|
279
|
-
it '
|
|
280
|
+
it 'supports array keys' do
|
|
280
281
|
subject.write([:fu, 'foo'], 'bar')
|
|
281
282
|
expect(subject.read('fu/foo')).to eq('bar')
|
|
282
283
|
end
|
|
283
284
|
|
|
284
|
-
it '
|
|
285
|
+
it 'supports hash keys' do
|
|
285
286
|
subject.write({ foo: 1, fu: 2 }, 'bar')
|
|
286
287
|
expect(subject.read('foo=1/fu=2')).to eq('bar')
|
|
287
288
|
end
|
|
288
289
|
|
|
289
|
-
it '
|
|
290
|
+
it 'is case sensitive' do
|
|
290
291
|
subject.write('foo', 'bar')
|
|
291
292
|
expect(subject.read('FOO')).to be_nil
|
|
292
293
|
end
|
|
293
294
|
end
|
|
294
295
|
|
|
295
296
|
describe 'with version' do
|
|
296
|
-
it '
|
|
297
|
+
it 'supports fetch/read' do
|
|
297
298
|
subject.fetch('foo', version: 1) { 'bar' }
|
|
298
299
|
expect(subject.read('foo', version: 1)).to eq('bar')
|
|
299
300
|
expect(subject.read('foo', version: 2)).to be_nil
|
|
300
301
|
end
|
|
301
302
|
|
|
302
|
-
it '
|
|
303
|
+
it 'supports write/read' do
|
|
303
304
|
subject.write('foo', 'bar', version: 1)
|
|
304
305
|
expect(subject.read('foo', version: 1)).to eq('bar')
|
|
305
306
|
expect(subject.read('foo', version: 2)).to be_nil
|
|
306
307
|
end
|
|
307
308
|
|
|
308
|
-
it '
|
|
309
|
+
it 'supports exists' do
|
|
309
310
|
subject.write('foo', 'bar', version: 1)
|
|
310
|
-
expect(subject.exist
|
|
311
|
-
expect(subject.exist
|
|
311
|
+
expect(subject).to exist('foo', version: 1)
|
|
312
|
+
expect(subject).not_to exist('foo', version: 2)
|
|
312
313
|
end
|
|
313
314
|
|
|
314
|
-
it '
|
|
315
|
+
it 'cache/versions keys' do
|
|
315
316
|
m1v1 = ModelWithKeyAndVersion.new('model/1', 1)
|
|
316
317
|
m1v2 = ModelWithKeyAndVersion.new('model/1', 2)
|
|
317
318
|
|
|
@@ -320,7 +321,7 @@ RSpec.describe ActiveSupport::Cache::DatabaseStore do
|
|
|
320
321
|
expect(subject.read(m1v2)).to be_nil
|
|
321
322
|
end
|
|
322
323
|
|
|
323
|
-
it '
|
|
324
|
+
it 'normalises' do
|
|
324
325
|
subject.write('foo', 'bar', version: 1)
|
|
325
326
|
expect(subject.read('foo', version: '1')).to eq('bar')
|
|
326
327
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: activesupport_cache_database
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Black Square Media Ltd
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-03-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activerecord
|
|
@@ -109,7 +109,7 @@ dependencies:
|
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
110
|
version: '0'
|
|
111
111
|
- !ruby/object:Gem::Dependency
|
|
112
|
-
name: rubocop
|
|
112
|
+
name: rubocop-bsm
|
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
|
114
114
|
requirements:
|
|
115
115
|
- - ">="
|
|
@@ -144,9 +144,9 @@ extensions: []
|
|
|
144
144
|
extra_rdoc_files: []
|
|
145
145
|
files:
|
|
146
146
|
- ".editorconfig"
|
|
147
|
+
- ".github/workflows/ruby.yml"
|
|
147
148
|
- ".gitignore"
|
|
148
149
|
- ".rubocop.yml"
|
|
149
|
-
- ".travis.yml"
|
|
150
150
|
- Gemfile
|
|
151
151
|
- Gemfile.lock
|
|
152
152
|
- LICENSE
|
|
@@ -171,14 +171,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
171
171
|
requirements:
|
|
172
172
|
- - ">="
|
|
173
173
|
- !ruby/object:Gem::Version
|
|
174
|
-
version: '2.
|
|
174
|
+
version: '2.6'
|
|
175
175
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
176
176
|
requirements:
|
|
177
177
|
- - ">="
|
|
178
178
|
- !ruby/object:Gem::Version
|
|
179
179
|
version: '0'
|
|
180
180
|
requirements: []
|
|
181
|
-
rubygems_version: 3.1.
|
|
181
|
+
rubygems_version: 3.1.4
|
|
182
182
|
signing_key:
|
|
183
183
|
specification_version: 4
|
|
184
184
|
summary: ActiveSupport::Cache::Store implementation backed by ActiveRecord.
|
data/.travis.yml
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
language: ruby
|
|
2
|
-
rvm:
|
|
3
|
-
- 2.6
|
|
4
|
-
- 2.5
|
|
5
|
-
before_install:
|
|
6
|
-
- gem install bundler
|
|
7
|
-
- mysql -e 'CREATE DATABASE ci_test;'
|
|
8
|
-
- psql -c 'CREATE DATABASE ci_test;' -U postgres
|
|
9
|
-
services:
|
|
10
|
-
- postgresql
|
|
11
|
-
- mysql
|
|
12
|
-
env:
|
|
13
|
-
- DATABASE_URL=sqlite3:///tmp/ci_test.sqlite3
|
|
14
|
-
- DATABASE_URL=mysql2://travis@127.0.0.1/ci_test
|
|
15
|
-
- DATABASE_URL=postgresql://127.0.0.1/ci_test
|