activesupport_cache_database 0.1.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 973852575f17d5bc8f4faf071724c054068e5ab070782dce02844a72d418dd2a
4
- data.tar.gz: 7551068640fe8e9c00f0e7e4474909d21bcd05b8881723fe6907f9b152e278c4
3
+ metadata.gz: c3b2183683fc6cb4ec9bb735da8fed61f9e057b894bfef685416dfb019d924ee
4
+ data.tar.gz: b493bb3f1a7aa74a27e87030fbefb98a3bf95cf98955bfbcf817382039776442
5
5
  SHA512:
6
- metadata.gz: 6420375b2577ed8f62df452e71d7d280d343d193666d52c36fa5a3aea4d57eac1e3ca81e902ad5ef141ce5190d829f488a8ec0686ee0d6b18481cdb55deadbd2
7
- data.tar.gz: d79407e5d25930e3b5fe96785b9e953c293a3eb7825c288525b1a73252b151b09ab7976fd1360adf4c43fb3ad55eba2e237071720c6f9473f2efbcab512a59a1
6
+ metadata.gz: 1ce1549296de2188bbfa524c8745844bb150d0df44e0d1472a617d716279deafe758b13b7c577dba84c00697b4aeca8fe8048bc96936fd2e17021accdc03777a
7
+ data.tar.gz: ae967fdb27b3597c4c1bc7ed58e57c6f4a59795a63dfc1df44caaae3b60ac3b53698df40131e8c17a0520202187e43e606a4f1cdb0471aaed0c1a7e4a1af6aab
@@ -0,0 +1,24 @@
1
+ name: Test
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.7", "3.0", "3.1"]
15
+ gemfiles: ["Gemfile", "Gemfile.rails6"]
16
+ env:
17
+ BUNDLE_GEMFILE: ${{ matrix.gemfile }}
18
+ steps:
19
+ - uses: actions/checkout@v3
20
+ - uses: ruby/setup-ruby@v1
21
+ with:
22
+ ruby-version: ${{ matrix.ruby-version }}
23
+ bundler-cache: true
24
+ - run: bundle exec rake
data/.rubocop.yml CHANGED
@@ -1,7 +1,15 @@
1
- inherit_from:
2
- - https://gitlab.com/bsm/misc/raw/master/rubocop/default.yml
3
-
1
+ inherit_gem:
2
+ rubocop-bsm:
3
+ - default.yml
4
+ inherit_mode:
5
+ merge:
6
+ - Exclude
4
7
  AllCops:
5
- TargetRubyVersion: "2.5"
8
+ TargetRubyVersion: "2.7"
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,81 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- activesupport_cache_database (0.1.2)
5
- activerecord (>= 5.0)
6
- activesupport (>= 5.0)
4
+ activesupport_cache_database (0.3.0)
5
+ activerecord (>= 6.0)
6
+ activesupport (>= 6.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activemodel (6.0.3.1)
12
- activesupport (= 6.0.3.1)
13
- activerecord (6.0.3.1)
14
- activemodel (= 6.0.3.1)
15
- activesupport (= 6.0.3.1)
16
- activesupport (6.0.3.1)
11
+ activemodel (7.0.3.1)
12
+ activesupport (= 7.0.3.1)
13
+ activerecord (7.0.3.1)
14
+ activemodel (= 7.0.3.1)
15
+ activesupport (= 7.0.3.1)
16
+ activesupport (7.0.3.1)
17
17
  concurrent-ruby (~> 1.0, >= 1.0.2)
18
- i18n (>= 0.7, < 2)
19
- minitest (~> 5.1)
20
- tzinfo (~> 1.1)
21
- zeitwerk (~> 2.2, >= 2.2.2)
22
- ast (2.4.0)
23
- concurrent-ruby (1.1.6)
24
- diff-lcs (1.3)
25
- i18n (1.8.2)
18
+ i18n (>= 1.6, < 2)
19
+ minitest (>= 5.1)
20
+ tzinfo (~> 2.0)
21
+ ast (2.4.2)
22
+ concurrent-ruby (1.1.10)
23
+ diff-lcs (1.5.0)
24
+ i18n (1.11.0)
26
25
  concurrent-ruby (~> 1.0)
27
- minitest (5.14.1)
28
- mysql2 (0.5.3)
29
- parallel (1.19.1)
30
- parser (2.7.1.3)
31
- ast (~> 2.4.0)
32
- pg (1.2.3)
33
- rainbow (3.0.0)
34
- rake (13.0.1)
35
- rexml (3.2.4)
36
- rspec (3.9.0)
37
- rspec-core (~> 3.9.0)
38
- rspec-expectations (~> 3.9.0)
39
- rspec-mocks (~> 3.9.0)
40
- rspec-core (3.9.2)
41
- rspec-support (~> 3.9.3)
42
- rspec-expectations (3.9.2)
26
+ json (2.6.2)
27
+ minitest (5.16.2)
28
+ mysql2 (0.5.4)
29
+ parallel (1.22.1)
30
+ parser (3.1.2.0)
31
+ ast (~> 2.4.1)
32
+ pg (1.4.1)
33
+ rainbow (3.1.1)
34
+ rake (13.0.6)
35
+ regexp_parser (2.5.0)
36
+ rexml (3.2.5)
37
+ rspec (3.11.0)
38
+ rspec-core (~> 3.11.0)
39
+ rspec-expectations (~> 3.11.0)
40
+ rspec-mocks (~> 3.11.0)
41
+ rspec-core (3.11.0)
42
+ rspec-support (~> 3.11.0)
43
+ rspec-expectations (3.11.0)
43
44
  diff-lcs (>= 1.2.0, < 2.0)
44
- rspec-support (~> 3.9.0)
45
- rspec-mocks (3.9.1)
45
+ rspec-support (~> 3.11.0)
46
+ rspec-mocks (3.11.1)
46
47
  diff-lcs (>= 1.2.0, < 2.0)
47
- rspec-support (~> 3.9.0)
48
- rspec-support (3.9.3)
49
- rubocop (0.84.0)
48
+ rspec-support (~> 3.11.0)
49
+ rspec-support (3.11.0)
50
+ rubocop (1.31.2)
51
+ json (~> 2.3)
50
52
  parallel (~> 1.10)
51
- parser (>= 2.7.0.1)
53
+ parser (>= 3.1.0.0)
52
54
  rainbow (>= 2.2.2, < 4.0)
53
- rexml
54
- rubocop-ast (>= 0.0.3)
55
+ regexp_parser (>= 1.8, < 3.0)
56
+ rexml (>= 3.2.5, < 4.0)
57
+ rubocop-ast (>= 1.18.0, < 2.0)
55
58
  ruby-progressbar (~> 1.7)
56
- unicode-display_width (>= 1.4.0, < 2.0)
57
- rubocop-ast (0.0.3)
58
- parser (>= 2.7.0.1)
59
- ruby-progressbar (1.10.1)
60
- sqlite3 (1.4.2)
61
- thread_safe (0.3.6)
62
- tzinfo (1.2.7)
63
- thread_safe (~> 0.1)
64
- unicode-display_width (1.7.0)
65
- zeitwerk (2.3.0)
59
+ unicode-display_width (>= 1.4.0, < 3.0)
60
+ rubocop-ast (1.19.1)
61
+ parser (>= 3.1.1.0)
62
+ rubocop-bsm (0.6.0)
63
+ rubocop (~> 1.0)
64
+ rubocop-performance
65
+ rubocop-rake
66
+ rubocop-rspec
67
+ rubocop-performance (1.14.2)
68
+ rubocop (>= 1.7.0, < 2.0)
69
+ rubocop-ast (>= 0.4.0)
70
+ rubocop-rake (0.6.0)
71
+ rubocop (~> 1.0)
72
+ rubocop-rspec (2.12.1)
73
+ rubocop (~> 1.31)
74
+ ruby-progressbar (1.11.0)
75
+ sqlite3 (1.4.4)
76
+ tzinfo (2.0.4)
77
+ concurrent-ruby (~> 1.0)
78
+ unicode-display_width (2.2.0)
66
79
 
67
80
  PLATFORMS
68
81
  ruby
@@ -74,8 +87,8 @@ DEPENDENCIES
74
87
  pg
75
88
  rake
76
89
  rspec
77
- rubocop
90
+ rubocop-bsm
78
91
  sqlite3
79
92
 
80
93
  BUNDLED WITH
81
- 2.1.4
94
+ 2.3.16
data/Gemfile.rails6 ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
4
+ gem 'activesupport', '~> 6.1'
5
+ gem 'activerecord', '~> 6.1'
@@ -0,0 +1,98 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ activesupport_cache_database (0.3.0)
5
+ activerecord (>= 5.0)
6
+ activesupport (>= 5.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activemodel (6.1.6.1)
12
+ activesupport (= 6.1.6.1)
13
+ activerecord (6.1.6.1)
14
+ activemodel (= 6.1.6.1)
15
+ activesupport (= 6.1.6.1)
16
+ activesupport (6.1.6.1)
17
+ concurrent-ruby (~> 1.0, >= 1.0.2)
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.10)
24
+ diff-lcs (1.5.0)
25
+ i18n (1.11.0)
26
+ concurrent-ruby (~> 1.0)
27
+ json (2.6.2)
28
+ minitest (5.16.2)
29
+ mysql2 (0.5.4)
30
+ parallel (1.22.1)
31
+ parser (3.1.2.0)
32
+ ast (~> 2.4.1)
33
+ pg (1.4.1)
34
+ rainbow (3.1.1)
35
+ rake (13.0.6)
36
+ regexp_parser (2.5.0)
37
+ rexml (3.2.5)
38
+ rspec (3.11.0)
39
+ rspec-core (~> 3.11.0)
40
+ rspec-expectations (~> 3.11.0)
41
+ rspec-mocks (~> 3.11.0)
42
+ rspec-core (3.11.0)
43
+ rspec-support (~> 3.11.0)
44
+ rspec-expectations (3.11.0)
45
+ diff-lcs (>= 1.2.0, < 2.0)
46
+ rspec-support (~> 3.11.0)
47
+ rspec-mocks (3.11.1)
48
+ diff-lcs (>= 1.2.0, < 2.0)
49
+ rspec-support (~> 3.11.0)
50
+ rspec-support (3.11.0)
51
+ rubocop (1.31.2)
52
+ json (~> 2.3)
53
+ parallel (~> 1.10)
54
+ parser (>= 3.1.0.0)
55
+ rainbow (>= 2.2.2, < 4.0)
56
+ regexp_parser (>= 1.8, < 3.0)
57
+ rexml (>= 3.2.5, < 4.0)
58
+ rubocop-ast (>= 1.18.0, < 2.0)
59
+ ruby-progressbar (~> 1.7)
60
+ unicode-display_width (>= 1.4.0, < 3.0)
61
+ rubocop-ast (1.19.1)
62
+ parser (>= 3.1.1.0)
63
+ rubocop-bsm (0.6.0)
64
+ rubocop (~> 1.0)
65
+ rubocop-performance
66
+ rubocop-rake
67
+ rubocop-rspec
68
+ rubocop-performance (1.14.2)
69
+ rubocop (>= 1.7.0, < 2.0)
70
+ rubocop-ast (>= 0.4.0)
71
+ rubocop-rake (0.6.0)
72
+ rubocop (~> 1.0)
73
+ rubocop-rspec (2.12.1)
74
+ rubocop (~> 1.31)
75
+ ruby-progressbar (1.11.0)
76
+ sqlite3 (1.4.4)
77
+ tzinfo (2.0.4)
78
+ concurrent-ruby (~> 1.0)
79
+ unicode-display_width (2.2.0)
80
+ zeitwerk (2.6.0)
81
+
82
+ PLATFORMS
83
+ x86_64-linux
84
+
85
+ DEPENDENCIES
86
+ activerecord (~> 6.1)
87
+ activesupport (~> 6.1)
88
+ activesupport_cache_database!
89
+ bundler
90
+ mysql2
91
+ pg
92
+ rake
93
+ rspec
94
+ rubocop-bsm
95
+ sqlite3
96
+
97
+ BUNDLED WITH
98
+ 2.3.16
data/LICENSE CHANGED
@@ -1,13 +1,201 @@
1
- Copyright 2019 Black Square Media Ltd
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
2
4
 
3
- Licensed under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License.
5
- You may obtain a copy of the License at
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
6
 
7
- http://www.apache.org/licenses/LICENSE-2.0
7
+ 1. Definitions.
8
8
 
9
- Unless required by applicable law or agreed to in writing, software
10
- distributed under the License is distributed on an "AS IS" BASIS,
11
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- See the License for the specific language governing permissions and
13
- limitations under the License.
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2021 Black Square Media Ltd
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ActiveSupport::Cache::DatabaseStore
2
2
 
3
- [![Build Status](https://travis-ci.org/bsm/activesupport-cache-database.png?branch=master)](https://travis-ci.org/bsm/activesupport-cache-database)
3
+ [![Test](https://github.com/bsm/activesupport-cache-database/actions/workflows/test.yml/badge.svg)](https://github.com/bsm/activesupport-cache-database/actions/workflows/test.yml)
4
4
  [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
5
5
 
6
6
  ActiveSupport::Cache::Store implementation backed by a database via ActiveRecord.
@@ -37,7 +37,9 @@ cache = ActiveSupport::Cache::DatabaseStore.new namespace: 'my-scope'
37
37
  value = cache.fetch('some-key') { 'default' }
38
38
  ```
39
39
 
40
- To use as a Rails cache store (not recommended!), simply use a new instance.
40
+ To use as a Rails cache store, simply use a new instance. Please keep in mind
41
+ that, for performance reasons, your database may not be the most suitable
42
+ general purpose cache backend.
41
43
 
42
44
  ```ruby
43
45
  config.cache_store = ActiveSupport::Cache::DatabaseStore.new
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'activesupport_cache_database'
3
- s.version = '0.1.2'
3
+ s.version = '0.3.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.)
@@ -9,18 +9,18 @@ Gem::Specification.new do |s|
9
9
  s.license = 'Apache-2.0'
10
10
 
11
11
  s.files = `git ls-files -z`.split("\x0").reject {|f| f.match(%r{^spec/}) }
12
- s.test_files = `git ls-files -z -- spec/*`.split("\x0")
13
12
  s.require_paths = ['lib']
14
- s.required_ruby_version = '>= 2.5'
13
+ s.required_ruby_version = '>= 2.7'
15
14
 
16
- s.add_dependency 'activerecord', '>= 5.0'
17
- s.add_dependency 'activesupport', '>= 5.0'
15
+ s.add_dependency 'activerecord', '>= 6.0'
16
+ s.add_dependency 'activesupport', '>= 6.0'
18
17
 
19
18
  s.add_development_dependency 'bundler'
20
19
  s.add_development_dependency 'mysql2'
21
20
  s.add_development_dependency 'pg'
22
21
  s.add_development_dependency 'rake'
23
22
  s.add_development_dependency 'rspec'
24
- s.add_development_dependency 'rubocop'
23
+ s.add_development_dependency 'rubocop-bsm'
25
24
  s.add_development_dependency 'sqlite3'
25
+ s.metadata['rubygems_mfa_required'] = 'true'
26
26
  end
@@ -13,6 +13,11 @@ module ActiveSupport
13
13
  autoload :Model, 'active_support/cache/database_store/model'
14
14
  autoload :Migration, 'active_support/cache/database_store/migration'
15
15
 
16
+ # Advertise cache versioning support.
17
+ def self.supports_cache_versioning?
18
+ true
19
+ end
20
+
16
21
  # param [Hash] options options
17
22
  # option options [Class] :model model class. Default: ActiveSupport::Cache::DatabaseStore::Model
18
23
  def initialize(options = nil)
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.1.2
4
+ version: 0.3.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: 2020-05-27 00:00:00.000000000 Z
11
+ date: 2022-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '5.0'
19
+ version: '6.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '5.0'
26
+ version: '6.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '5.0'
33
+ version: '6.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '5.0'
40
+ version: '6.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -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,11 +144,13 @@ extensions: []
144
144
  extra_rdoc_files: []
145
145
  files:
146
146
  - ".editorconfig"
147
+ - ".github/workflows/test.yml"
147
148
  - ".gitignore"
148
149
  - ".rubocop.yml"
149
- - ".travis.yml"
150
150
  - Gemfile
151
151
  - Gemfile.lock
152
+ - Gemfile.rails6
153
+ - Gemfile.rails6.lock
152
154
  - LICENSE
153
155
  - README.md
154
156
  - Rakefile
@@ -157,12 +159,11 @@ files:
157
159
  - lib/active_support/cache/database_store/migration.rb
158
160
  - lib/active_support/cache/database_store/model.rb
159
161
  - lib/activesupport_cache_database.rb
160
- - spec/active_support/cache/database_store_spec.rb
161
- - spec/spec_helper.rb
162
162
  homepage: https://github.com/bsm/activesupport-cache-database
163
163
  licenses:
164
164
  - Apache-2.0
165
- metadata: {}
165
+ metadata:
166
+ rubygems_mfa_required: 'true'
166
167
  post_install_message:
167
168
  rdoc_options: []
168
169
  require_paths:
@@ -171,17 +172,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
171
172
  requirements:
172
173
  - - ">="
173
174
  - !ruby/object:Gem::Version
174
- version: '2.5'
175
+ version: '2.7'
175
176
  required_rubygems_version: !ruby/object:Gem::Requirement
176
177
  requirements:
177
178
  - - ">="
178
179
  - !ruby/object:Gem::Version
179
180
  version: '0'
180
181
  requirements: []
181
- rubygems_version: 3.1.2
182
+ rubygems_version: 3.3.7
182
183
  signing_key:
183
184
  specification_version: 4
184
185
  summary: ActiveSupport::Cache::Store implementation backed by ActiveRecord.
185
- test_files:
186
- - spec/active_support/cache/database_store_spec.rb
187
- - spec/spec_helper.rb
186
+ test_files: []
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
@@ -1,328 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe ActiveSupport::Cache::DatabaseStore do
4
- subject do
5
- described_class.new expires_in: 60
6
- end
7
-
8
- it 'should read and write strings' do
9
- expect(subject.write('foo', 'bar')).to be_truthy
10
- expect(subject.read('foo')).to eq('bar')
11
- end
12
-
13
- it 'should read and write hash' do
14
- expect(subject.write('foo', a: 'b')).to be_truthy
15
- expect(subject.read('foo')).to eq(a: 'b')
16
- end
17
-
18
- it 'should read and write integer' do
19
- expect(subject.write('foo', 1)).to be_truthy
20
- expect(subject.read('foo')).to eq(1)
21
- end
22
-
23
- it 'should read and write nil' do
24
- expect(subject.write('foo', nil)).to be_truthy
25
- expect(subject.read('foo')).to eq(nil)
26
- end
27
-
28
- it 'should read and write false' do
29
- expect(subject.write('foo', false)).to be_truthy
30
- expect(subject.read('foo')).to eq(false)
31
- end
32
-
33
- it 'should overwrite' do
34
- expect(subject.write('foo', 'bar')).to be_truthy
35
- expect(subject.write('foo', 'baz')).to be_truthy
36
- expect(subject.read('foo')).to eq('baz')
37
- end
38
-
39
- it 'should support exist?' do
40
- subject.write('foo', 'bar')
41
- expect(subject.exist?('foo')).to be_truthy
42
- expect(subject.exist?('bar')).to be_falsey
43
- end
44
-
45
- it 'should support nil exist?' do
46
- subject.write('foo', nil)
47
- expect(subject.exist?('foo')).to be_truthy
48
- end
49
-
50
- it 'should support delete' do
51
- subject.write('foo', 'bar')
52
- expect(subject.exist?('foo')).to be_truthy
53
- expect(subject.delete('foo')).to be_truthy
54
- expect(subject.exist?('foo')).to be_falsey
55
- end
56
-
57
- it 'should support expires_in' do
58
- time = Time.local(2008, 4, 24)
59
- allow(Time).to receive(:now).and_return(time)
60
-
61
- subject.write('foo', 'bar')
62
- expect(subject.read('foo')).to eq('bar')
63
-
64
- allow(Time).to receive(:now).and_return(time + 30)
65
- expect(subject.read('foo')).to eq('bar')
66
-
67
- allow(Time).to receive(:now).and_return(time + 61)
68
- expect(subject.read('foo')).to be_nil
69
- end
70
-
71
- it 'should support long keys' do
72
- key = 'x' * 255
73
- expect(subject.write(key, 'bar')).to be_truthy
74
- expect(subject.read(key)).to eq('bar')
75
- expect(subject.fetch(key)).to eq('bar')
76
- expect(subject.read(key[0..-2])).to be_nil
77
- expect(subject.read_multi(key)).to eq(key => 'bar')
78
- expect(subject.delete(key)).to be_truthy
79
-
80
- expect { subject.write("#{key}x", 'bar') }.to raise_error(ArgumentError, /exceeds the length limit/)
81
- expect { subject.read("#{key}x") }.to raise_error(ArgumentError, /exceeds the length limit/)
82
- end
83
-
84
- describe '#cleanup' do
85
- it 'should delete expired' do
86
- time = Time.now
87
- subject.write('foo', 'bar', expires_in: 10)
88
- subject.write('fud', 'biz', expires_in: 20)
89
-
90
- allow(Time).to receive(:now).and_return(time + 9)
91
- expect(subject.cleanup).to eq(0)
92
-
93
- allow(Time).to receive(:now).and_return(time + 19)
94
- expect(subject.cleanup).to eq(1)
95
- expect(subject.read('foo')).to be_nil
96
- expect(subject.read('fud')).to eq('biz')
97
- end
98
-
99
- it 'should support namespace' do
100
- time = Time.now
101
- subject.write('foo', 'bar', expires_in: 10, namespace: 'x')
102
- subject.write('foo', 'biz', expires_in: 10, namespace: 'y')
103
-
104
- allow(Time).to receive(:now).and_return(time + 11)
105
- expect(subject.count).to eq(0)
106
- expect(subject.count(all: true)).to eq(2)
107
-
108
- expect(subject.cleanup(namespace: 'x')).to eq(1)
109
- expect(subject.count).to eq(0)
110
- expect(subject.count(all: true)).to eq(1)
111
- end
112
- end
113
-
114
- describe '#clear' do
115
- it 'should remove all entries' do
116
- subject.write('foo', 'bar')
117
- subject.write('fud', 'biz')
118
- expect(subject.clear).to be_truthy
119
- expect(subject.read('foo')).to be_nil
120
- expect(subject.read('fud')).to be_nil
121
- end
122
-
123
- it 'should support namespace' do
124
- subject.write('foo', 'bar', namespace: 'x')
125
- subject.write('foo', 'biz', namespace: 'y')
126
- expect(subject.count).to eq(2)
127
-
128
- expect(subject.clear(namespace: 'x')).to be_truthy
129
- expect(subject.count).to eq(1)
130
- end
131
- end
132
-
133
- describe '#fetch' do
134
- it 'should support cache hit' do
135
- subject.write('foo', 'bar')
136
- expect(subject).not_to receive(:write)
137
-
138
- expect(subject.fetch('foo') { 'baz' }).to eq('bar')
139
- end
140
-
141
- it 'should support cache miss' do
142
- expect(subject).to receive(:write).with('foo', 'baz', instance_of(Hash))
143
- expect(subject.fetch('foo') { 'baz' }).to eq('baz')
144
- end
145
-
146
- it 'should pass key to block on cache miss' do
147
- cache_miss = false
148
- expect(subject.fetch('foo') {|key| cache_miss = true; key.length }).to eq(3)
149
- expect(cache_miss).to be_truthy
150
-
151
- cache_miss = false
152
- expect(subject.fetch('foo') {|key| cache_miss = true; key.length }).to eq(3)
153
- expect(cache_miss).to be_falsey
154
- end
155
-
156
- it 'should support forced cache miss' do
157
- subject.write('foo', 'bar')
158
- expect(subject).not_to receive(:read)
159
-
160
- expect(subject.fetch('foo', force: true) { 'baz' }).to eq('baz')
161
- end
162
-
163
- it 'should support nil values' do
164
- subject.write('foo', nil)
165
- expect(subject).not_to receive(:write)
166
-
167
- expect(subject.fetch('foo') { 'baz' }).to be_nil
168
- end
169
-
170
- it 'should support skip_nil option' do
171
- expect(subject).not_to receive(:write)
172
- expect(subject.fetch('foo', skip_nil: true) { nil }).to be_nil
173
- expect(subject.exist?('foo')).to be_falsey
174
- end
175
-
176
- it 'should support forced cache miss with block' do
177
- subject.write('foo', 'bar')
178
- expect(subject.fetch('foo', force: true) { 'baz' }).to eq('baz')
179
- end
180
-
181
- it 'should support forced cache miss without block' do
182
- subject.write('foo', 'bar')
183
- expect { subject.fetch('foo', force: true) }.to raise_error(ArgumentError)
184
- expect(subject.read('foo')).to eq('bar')
185
- end
186
- end
187
-
188
- describe '#read_multi' do
189
- it 'should support read_multi' do
190
- subject.write('foo', 'bar')
191
- subject.write('fu', 'baz')
192
- subject.write('fud', 'biz')
193
- expect(subject.read_multi('foo', 'fu')).to eq('foo' => 'bar', 'fu' => 'baz')
194
- end
195
-
196
- it 'should support expires' do
197
- time = Time.now
198
- subject.write('foo', 'bar', expires_in: 10)
199
- subject.write('fu', 'baz')
200
- subject.write('fud', 'biz')
201
-
202
- allow(Time).to receive(:now).and_return(time + 11)
203
- expect(subject.read_multi('foo', 'fu')).to eq('fu' => 'baz')
204
- end
205
- end
206
-
207
- describe '#fetch_multi' do
208
- it 'should support fetch_multi' do
209
- subject.write('foo', 'bar')
210
- subject.write('fud', 'biz')
211
- values = subject.fetch_multi('foo', 'fu', 'fud') {|v| v * 2 }
212
-
213
- expect(values).to eq('foo' => 'bar', 'fu' => 'fufu', 'fud' => 'biz')
214
- expect(subject.read('fu')).to eq('fufu')
215
- end
216
-
217
- it 'should support without expires_in' do
218
- subject.write('foo', 'bar')
219
- subject.write('fud', 'biz')
220
- values = subject.fetch_multi('foo', 'fu', 'fud', expires_in: nil) {|v| v * 2 }
221
-
222
- expect(values).to eq('foo' => 'bar', 'fu' => 'fufu', 'fud' => 'biz')
223
- expect(subject.read('fu')).to eq('fufu')
224
- end
225
-
226
- it 'should support with objects' do
227
- cache_struct = Struct.new(:cache_key, :title)
228
- foo = cache_struct.new('foo', 'FOO!')
229
- bar = cache_struct.new('bar')
230
-
231
- subject.write('bar', 'BAM!')
232
- values = subject.fetch_multi(foo, bar, &:title)
233
- expect(values).to eq(foo => 'FOO!', bar => 'BAM!')
234
- end
235
-
236
- it 'should support ordered names' do
237
- subject.write('bam', 'BAM')
238
- values = subject.fetch_multi('foo', 'bar', 'bam', &:upcase)
239
- expect(values.keys).to eq(%w[foo bar bam])
240
- end
241
-
242
- it 'should raise without block' do
243
- expect { subject.fetch_multi('foo') }.to raise_error(ArgumentError)
244
- end
245
- end
246
-
247
- describe 'cache key' do
248
- it 'should support cache keys' do
249
- obj = Object.new
250
- def obj.cache_key
251
- :foo
252
- end
253
- subject.write(obj, 'bar')
254
- expect(subject.read('foo')).to eq('bar')
255
- end
256
-
257
- it 'should support to_param keys' do
258
- obj = Object.new
259
- def obj.to_param
260
- :foo
261
- end
262
- subject.write(obj, 'bar')
263
- expect(subject.read('foo')).to eq('bar')
264
- end
265
-
266
- it 'should support unversioned keys' do
267
- obj = Object.new
268
- def obj.cache_key
269
- :foo
270
- end
271
-
272
- def obj.cache_key_with_version
273
- 'foo-v1'
274
- end
275
- subject.write(obj, 'bar')
276
- expect(subject.read('foo')).to eq('bar')
277
- end
278
-
279
- it 'should support array keys' do
280
- subject.write([:fu, 'foo'], 'bar')
281
- expect(subject.read('fu/foo')).to eq('bar')
282
- end
283
-
284
- it 'should support hash keys' do
285
- subject.write({ foo: 1, fu: 2 }, 'bar')
286
- expect(subject.read('foo=1/fu=2')).to eq('bar')
287
- end
288
-
289
- it 'should be case sensitive' do
290
- subject.write('foo', 'bar')
291
- expect(subject.read('FOO')).to be_nil
292
- end
293
- end
294
-
295
- describe 'with version' do
296
- it 'should support fetch/read' do
297
- subject.fetch('foo', version: 1) { 'bar' }
298
- expect(subject.read('foo', version: 1)).to eq('bar')
299
- expect(subject.read('foo', version: 2)).to be_nil
300
- end
301
-
302
- it 'should support write/read' do
303
- subject.write('foo', 'bar', version: 1)
304
- expect(subject.read('foo', version: 1)).to eq('bar')
305
- expect(subject.read('foo', version: 2)).to be_nil
306
- end
307
-
308
- it 'should support exists' do
309
- subject.write('foo', 'bar', version: 1)
310
- expect(subject.exist?('foo', version: 1)).to be_truthy
311
- expect(subject.exist?('foo', version: 2)).to be_falsey
312
- end
313
-
314
- it 'should cache/version keys' do
315
- m1v1 = ModelWithKeyAndVersion.new('model/1', 1)
316
- m1v2 = ModelWithKeyAndVersion.new('model/1', 2)
317
-
318
- subject.write(m1v1, 'bar')
319
- expect(subject.read(m1v1)).to eq('bar')
320
- expect(subject.read(m1v2)).to be_nil
321
- end
322
-
323
- it 'should normalise' do
324
- subject.write('foo', 'bar', version: 1)
325
- expect(subject.read('foo', version: '1')).to eq('bar')
326
- end
327
- end
328
- end
data/spec/spec_helper.rb DELETED
@@ -1,30 +0,0 @@
1
- ENV['RACK_ENV'] ||= 'test'
2
-
3
- require 'rspec'
4
- require 'fileutils'
5
- require 'activesupport_cache_database'
6
-
7
- Time.zone_default = Time.find_zone!('UTC')
8
-
9
- database_url = ENV.fetch('DATABASE_URL') do
10
- path = File.expand_path('./test.sqlite3', __dir__)
11
- FileUtils.rm_f(path)
12
- "sqlite3://#{path}"
13
- end
14
- ActiveRecord::Base.configurations = { 'test' => { 'url' => database_url, 'pool' => 20 } }
15
-
16
- ActiveRecord::Base.establish_connection :test
17
- ActiveRecord::Base.connection.instance_eval do
18
- drop_table 'activesupport_cache_entries', if_exists: true
19
- end
20
- ActiveRecord::Migration.suppress_messages do
21
- ActiveSupport::Cache::DatabaseStore::Migration.migrate(:up)
22
- end
23
-
24
- RSpec.configure do |c|
25
- c.after :each do
26
- ActiveSupport::Cache::DatabaseStore::Model.truncate!
27
- end
28
- end
29
-
30
- ModelWithKeyAndVersion = Struct.new(:cache_key, :cache_version)