activesupport_cache_database 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +36 -30
- data/activesupport_cache_database.gemspec +1 -2
- data/lib/active_support/cache/database_store/model.rb +2 -3
- data/lib/active_support/cache/database_store.rb +22 -0
- metadata +4 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 858311266f294e87e4a3c96d9fdaa64fe35c7038b5e6949e9f460c65c694def3
|
4
|
+
data.tar.gz: 8d2a67ebeac765e4f953e6fbc595a17e8eadacad6d678c534de4d86296dff30d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd6fadeb496e34d88d93def2efd1c2d6cd0db3617f71e129698e17a421ab7e0b365438d8cac945df1d0f4a07a03f8bee06e0f2f03e2b803f05cb12289f47f8b4
|
7
|
+
data.tar.gz: 6d51e3d506c5dab9d8fbf68063d033808bbfbe2f006c851ca73dbec3e0b552196522e8fa60b4f6b161e37d17de6c078a2c1ad8555f1635d5316cf47e235351df
|
data/CHANGELOG.md
ADDED
data/Gemfile.lock
CHANGED
@@ -1,82 +1,89 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
activesupport_cache_database (0.
|
4
|
+
activesupport_cache_database (0.4.0)
|
5
5
|
activerecord (>= 6.0)
|
6
6
|
activesupport (>= 6.0)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activemodel (7.0.
|
12
|
-
activesupport (= 7.0.
|
13
|
-
activerecord (7.0.
|
14
|
-
activemodel (= 7.0.
|
15
|
-
activesupport (= 7.0.
|
16
|
-
activesupport (7.0.
|
11
|
+
activemodel (7.0.6)
|
12
|
+
activesupport (= 7.0.6)
|
13
|
+
activerecord (7.0.6)
|
14
|
+
activemodel (= 7.0.6)
|
15
|
+
activesupport (= 7.0.6)
|
16
|
+
activesupport (7.0.6)
|
17
17
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
18
18
|
i18n (>= 1.6, < 2)
|
19
19
|
minitest (>= 5.1)
|
20
20
|
tzinfo (~> 2.0)
|
21
21
|
ast (2.4.2)
|
22
|
-
concurrent-ruby (1.2.
|
22
|
+
concurrent-ruby (1.2.2)
|
23
23
|
diff-lcs (1.5.0)
|
24
|
-
i18n (1.
|
24
|
+
i18n (1.14.1)
|
25
25
|
concurrent-ruby (~> 1.0)
|
26
26
|
json (2.6.3)
|
27
|
-
|
28
|
-
|
27
|
+
language_server-protocol (3.17.0.3)
|
28
|
+
mini_portile2 (2.8.2)
|
29
|
+
minitest (5.18.1)
|
29
30
|
mysql2 (0.5.5)
|
30
|
-
parallel (1.
|
31
|
-
parser (3.2.
|
31
|
+
parallel (1.23.0)
|
32
|
+
parser (3.2.2.3)
|
32
33
|
ast (~> 2.4.1)
|
33
|
-
|
34
|
+
racc
|
35
|
+
pg (1.5.3)
|
36
|
+
racc (1.7.1)
|
34
37
|
rainbow (3.1.1)
|
35
38
|
rake (13.0.6)
|
36
|
-
regexp_parser (2.
|
39
|
+
regexp_parser (2.8.1)
|
37
40
|
rexml (3.2.5)
|
38
41
|
rspec (3.12.0)
|
39
42
|
rspec-core (~> 3.12.0)
|
40
43
|
rspec-expectations (~> 3.12.0)
|
41
44
|
rspec-mocks (~> 3.12.0)
|
42
|
-
rspec-core (3.12.
|
45
|
+
rspec-core (3.12.2)
|
43
46
|
rspec-support (~> 3.12.0)
|
44
|
-
rspec-expectations (3.12.
|
47
|
+
rspec-expectations (3.12.3)
|
45
48
|
diff-lcs (>= 1.2.0, < 2.0)
|
46
49
|
rspec-support (~> 3.12.0)
|
47
|
-
rspec-mocks (3.12.
|
50
|
+
rspec-mocks (3.12.6)
|
48
51
|
diff-lcs (>= 1.2.0, < 2.0)
|
49
52
|
rspec-support (~> 3.12.0)
|
50
|
-
rspec-support (3.12.
|
51
|
-
rubocop (1.
|
53
|
+
rspec-support (3.12.1)
|
54
|
+
rubocop (1.54.2)
|
52
55
|
json (~> 2.3)
|
56
|
+
language_server-protocol (>= 3.17.0)
|
53
57
|
parallel (~> 1.10)
|
54
|
-
parser (>= 3.2.
|
58
|
+
parser (>= 3.2.2.3)
|
55
59
|
rainbow (>= 2.2.2, < 4.0)
|
56
60
|
regexp_parser (>= 1.8, < 3.0)
|
57
61
|
rexml (>= 3.2.5, < 4.0)
|
58
|
-
rubocop-ast (>= 1.
|
62
|
+
rubocop-ast (>= 1.28.0, < 2.0)
|
59
63
|
ruby-progressbar (~> 1.7)
|
60
64
|
unicode-display_width (>= 2.4.0, < 3.0)
|
61
|
-
rubocop-ast (1.
|
62
|
-
parser (>= 3.
|
65
|
+
rubocop-ast (1.29.0)
|
66
|
+
parser (>= 3.2.1.0)
|
63
67
|
rubocop-bsm (0.6.1)
|
64
68
|
rubocop (~> 1.0)
|
65
69
|
rubocop-performance
|
66
70
|
rubocop-rake
|
67
71
|
rubocop-rspec
|
68
|
-
rubocop-capybara (2.
|
72
|
+
rubocop-capybara (2.18.0)
|
69
73
|
rubocop (~> 1.41)
|
70
|
-
rubocop-
|
74
|
+
rubocop-factory_bot (2.23.1)
|
75
|
+
rubocop (~> 1.33)
|
76
|
+
rubocop-performance (1.18.0)
|
71
77
|
rubocop (>= 1.7.0, < 2.0)
|
72
78
|
rubocop-ast (>= 0.4.0)
|
73
79
|
rubocop-rake (0.6.0)
|
74
80
|
rubocop (~> 1.0)
|
75
|
-
rubocop-rspec (2.
|
81
|
+
rubocop-rspec (2.22.0)
|
76
82
|
rubocop (~> 1.33)
|
77
83
|
rubocop-capybara (~> 2.17)
|
78
|
-
|
79
|
-
|
84
|
+
rubocop-factory_bot (~> 2.22)
|
85
|
+
ruby-progressbar (1.13.0)
|
86
|
+
sqlite3 (1.6.3)
|
80
87
|
mini_portile2 (~> 2.8.0)
|
81
88
|
tzinfo (2.0.6)
|
82
89
|
concurrent-ruby (~> 1.0)
|
@@ -87,7 +94,6 @@ PLATFORMS
|
|
87
94
|
|
88
95
|
DEPENDENCIES
|
89
96
|
activesupport_cache_database!
|
90
|
-
bundler
|
91
97
|
mysql2
|
92
98
|
pg
|
93
99
|
rake
|
@@ -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.4.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.)
|
@@ -15,6 +15,5 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.add_dependency 'activerecord', '>= 6.0'
|
16
16
|
s.add_dependency 'activesupport', '>= 6.0'
|
17
17
|
|
18
|
-
s.add_development_dependency 'bundler'
|
19
18
|
s.metadata['rubygems_mfa_required'] = 'true'
|
20
19
|
end
|
@@ -12,11 +12,10 @@ module ActiveSupport
|
|
12
12
|
|
13
13
|
scope :fresh, -> { where(arel_table[:expires_at].gt(Time.zone.now)) }
|
14
14
|
scope :expired, -> { where(arel_table[:expires_at].lteq(Time.zone.now)) }
|
15
|
+
scope :created_before, ->(date = 1.month.ago) { where(arel_table[:created_at].lt(date)) }
|
15
16
|
|
16
17
|
def self.namespaced(namespace)
|
17
|
-
|
18
|
-
clause = ::Arel::Nodes::NamedFunction.new('SUBSTR', [arel_table[:key], 1, prefix.bytesize])
|
19
|
-
where clause.eq(prefix)
|
18
|
+
where(arel_table[:key].matches("#{namespace}:%"))
|
20
19
|
end
|
21
20
|
end
|
22
21
|
end
|
@@ -26,16 +26,31 @@ module ActiveSupport
|
|
26
26
|
end
|
27
27
|
|
28
28
|
# Preemptively iterates through all stored keys and removes the ones which have expired.
|
29
|
+
|
30
|
+
# params [Hash] options
|
31
|
+
# option options [String] :namespace
|
32
|
+
# option options [ActiveSupport::Duration] :created_before - provide a time duration after record without expire_at date will get removed.
|
29
33
|
def cleanup(options = nil)
|
30
34
|
options = merged_options(options)
|
31
35
|
scope = @model.expired
|
36
|
+
|
37
|
+
if (created_before = options[:created_before])
|
38
|
+
scope = scope.or(@model.created_before(created_before))
|
39
|
+
end
|
40
|
+
|
32
41
|
if (namespace = options[:namespace])
|
33
42
|
scope = scope.namespaced(namespace)
|
34
43
|
end
|
44
|
+
|
35
45
|
scope.delete_all
|
36
46
|
end
|
37
47
|
|
38
48
|
# Clears the entire cache. Be careful with this method.
|
49
|
+
#
|
50
|
+
# params [Hash] options
|
51
|
+
# option options [String] :namespace
|
52
|
+
#
|
53
|
+
# @return [Boolean]
|
39
54
|
def clear(options = nil)
|
40
55
|
options = merged_options(options)
|
41
56
|
if (namespace = options[:namespace])
|
@@ -74,6 +89,13 @@ module ActiveSupport
|
|
74
89
|
record = @model.where(key: key).first_or_initialize
|
75
90
|
expires_at = Time.zone.at(entry.expires_at) if entry.expires_at
|
76
91
|
record.update! value: Marshal.dump(entry.value), version: entry.version.presence, expires_at: expires_at
|
92
|
+
rescue ActiveRecord::RecordNotUnique
|
93
|
+
# If two servers initialize a new record with the same cache key and try to save it,
|
94
|
+
# the saves will race. We do not need to ensure a specific save wins, but we do need to ensure
|
95
|
+
# that at least one of the saves succeeds and that none of the saves raise an exception.
|
96
|
+
# In practive it means that if there alread was a save that "won" from us and completed earlier
|
97
|
+
# we don't need to do anything.
|
98
|
+
true
|
77
99
|
end
|
78
100
|
|
79
101
|
def delete_entry(key, _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.
|
4
|
+
version: 0.4.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: 2023-
|
11
|
+
date: 2023-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -38,20 +38,6 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '6.0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: bundler
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
41
|
description: Use your DB as a cache store
|
56
42
|
email:
|
57
43
|
- info@blacksquaremedia.com
|
@@ -63,6 +49,7 @@ files:
|
|
63
49
|
- ".github/workflows/test.yml"
|
64
50
|
- ".gitignore"
|
65
51
|
- ".rubocop.yml"
|
52
|
+
- CHANGELOG.md
|
66
53
|
- Gemfile
|
67
54
|
- Gemfile.lock
|
68
55
|
- Gemfile.rails6
|
@@ -95,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
82
|
- !ruby/object:Gem::Version
|
96
83
|
version: '0'
|
97
84
|
requirements: []
|
98
|
-
rubygems_version: 3.
|
85
|
+
rubygems_version: 3.4.9
|
99
86
|
signing_key:
|
100
87
|
specification_version: 4
|
101
88
|
summary: ActiveSupport::Cache::Store implementation backed by ActiveRecord.
|