activesupport_cache_database 0.3.2 → 0.4.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: '0840ceacca7159f5b4abd0ac006342cac7852ee2bcd8b993c81d43393ec2579e'
4
- data.tar.gz: e25a5fde4bb9c870ef23df5f5ba8215f68504b366ddac2ea5cdab2dacddcba1c
3
+ metadata.gz: 858311266f294e87e4a3c96d9fdaa64fe35c7038b5e6949e9f460c65c694def3
4
+ data.tar.gz: 8d2a67ebeac765e4f953e6fbc595a17e8eadacad6d678c534de4d86296dff30d
5
5
  SHA512:
6
- metadata.gz: 718e24bd6dc5c98cd7c5694c8dc92a759725b53dede1076c5d6079d2ce956676f68b0fa0e20f9f17176d4a11162922185b1feded4073b34cf09b87804628a058
7
- data.tar.gz: 1b463a7fa6e6c297f5a2c68cf16bde3565b33e9a6e03922a3109d8bf329aaa1b08046b509954ee56bce7c072f54101f7abeaca7fb90f51c506411680b297795d
6
+ metadata.gz: cd6fadeb496e34d88d93def2efd1c2d6cd0db3617f71e129698e17a421ab7e0b365438d8cac945df1d0f4a07a03f8bee06e0f2f03e2b803f05cb12289f47f8b4
7
+ data.tar.gz: 6d51e3d506c5dab9d8fbf68063d033808bbfbe2f006c851ca73dbec3e0b552196522e8fa60b4f6b161e37d17de6c078a2c1ad8555f1635d5316cf47e235351df
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # Changelog
2
+
3
+ ## v0.4.0 (2023-07-18)
4
+
5
+ ### New Features
6
+
7
+ - Allow to clean up cache entries without `expire_at` [#24](https://github.com/bsm/extsort/pull/24)
data/Gemfile.lock CHANGED
@@ -1,19 +1,19 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- activesupport_cache_database (0.3.2)
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.4.2)
12
- activesupport (= 7.0.4.2)
13
- activerecord (7.0.4.2)
14
- activemodel (= 7.0.4.2)
15
- activesupport (= 7.0.4.2)
16
- activesupport (7.0.4.2)
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)
@@ -21,62 +21,69 @@ GEM
21
21
  ast (2.4.2)
22
22
  concurrent-ruby (1.2.2)
23
23
  diff-lcs (1.5.0)
24
- i18n (1.12.0)
24
+ i18n (1.14.1)
25
25
  concurrent-ruby (~> 1.0)
26
26
  json (2.6.3)
27
- mini_portile2 (2.8.1)
28
- minitest (5.17.0)
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.22.1)
31
- parser (3.2.1.0)
31
+ parallel (1.23.0)
32
+ parser (3.2.2.3)
32
33
  ast (~> 2.4.1)
33
- pg (1.4.6)
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.7.0)
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.1)
45
+ rspec-core (3.12.2)
43
46
  rspec-support (~> 3.12.0)
44
- rspec-expectations (3.12.2)
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.3)
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.0)
51
- rubocop (1.47.0)
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.0.0)
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.26.0, < 2.0)
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.27.0)
65
+ rubocop-ast (1.29.0)
62
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.17.1)
72
+ rubocop-capybara (2.18.0)
69
73
  rubocop (~> 1.41)
70
- rubocop-performance (1.16.0)
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.18.1)
81
+ rubocop-rspec (2.22.0)
76
82
  rubocop (~> 1.33)
77
83
  rubocop-capybara (~> 2.17)
78
- ruby-progressbar (1.11.0)
79
- sqlite3 (1.6.1)
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)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'activesupport_cache_database'
3
- s.version = '0.3.2'
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.)
@@ -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
- prefix = "#{namespace}:"
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])
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.3.2
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-03-01 00:00:00.000000000 Z
11
+ date: 2023-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -49,6 +49,7 @@ files:
49
49
  - ".github/workflows/test.yml"
50
50
  - ".gitignore"
51
51
  - ".rubocop.yml"
52
+ - CHANGELOG.md
52
53
  - Gemfile
53
54
  - Gemfile.lock
54
55
  - Gemfile.rails6
@@ -81,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
82
  - !ruby/object:Gem::Version
82
83
  version: '0'
83
84
  requirements: []
84
- rubygems_version: 3.4.6
85
+ rubygems_version: 3.4.9
85
86
  signing_key:
86
87
  specification_version: 4
87
88
  summary: ActiveSupport::Cache::Store implementation backed by ActiveRecord.