ar_cache 1.4.0 → 1.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 56df5f788fb94d493c94dca6942c80819ae1fa1c567b9b6228020ad935c35c4f
4
- data.tar.gz: 2b253f18c8174b39159f6bb0c79f298c0064a35c05ac4334719e6ca50db13a26
3
+ metadata.gz: 86d921c69c8ac7d8cbc0cefdb5614120a60f5663c5a2b8e3bc07a1c9c1d8d8a0
4
+ data.tar.gz: ced6d5cf673fb6e83070ba95e4daf6fb9d0994a93f8963de63692317c9c77081
5
5
  SHA512:
6
- metadata.gz: 536189cb015607a2fd12c85f03f995ae7443b5a019e72b37526cb371a994182bad76a010c0b2f05e06be1041fee7e5bb7177ebe946155a5de73df827a66521d6
7
- data.tar.gz: f65ea53cc987f2b3aed000408fd8b70da94dfc56a27f04db5e0aed33dac41ad7838aec761640cbff037fa7d733c5b538428154f6e082533051a20a8bf5740b52
6
+ metadata.gz: 5affbd42eed0837bc8fc40fd317eac39fa79b0e18c8e27f65eefb2873b381064539374dde7b963c1993f66068177707e72421499d7ff81b5fdc394e91261f8c3
7
+ data.tar.gz: 1c7f9930f0a726201afa735d208c229c01693432adc1631ea5bcd6417210ad079587c18ac9e908890e4ae4fac2307361048f017a28308c92c22d9136dd36e5ce
data/CHANGELOG.md CHANGED
@@ -2,20 +2,30 @@
2
2
 
3
3
  ## main
4
4
 
5
+ ## 1.5.0 (2021-03-22 UTC)
6
+
7
+ [Compare [#7cc9ec8..10f9eea](https://github.com/OuYangJinTing/ar_cache/compare/7cc9ec8..10f9eea)]:
8
+
9
+ - Fix `has_one thtough:` strict loading error.
10
+ - Fix `#detect_wrong_key`, should check `nil` value match.
11
+ - Rename `ArCache::Configuration#index_column_max_size` => `ArCache::Configuration#column_length`
12
+
5
13
  ## 1.4.0 (2021-03-15 UTC)
6
14
 
7
- [Commit [#7cc9ec8](https://github.com/OuYangJinTing/ar_cache/commit/7cc9ec8047394bb7758e25edd3b42fa48bb88640)]:
15
+ [Compare [#3ff0bb8..7cc9ec8](https://github.com/OuYangJinTing/ar_cache/compare/3ff0bb8..7cc9ec8)]:
8
16
 
9
17
  - Remove `ArCache::Table` `ignored_columns` configuration.
10
18
  - Fix `ActiveRecord` call `#select` write to cache data is incomplete.
11
19
 
12
20
  ## 1.3.0 (2021-03-13 UTC)
13
21
 
14
- - [Commit [#4ec14e9](https://github.com/OuYangJinTing/ar_cache/commit/4ec14e9e762abb57a8ff18aa8c93a514db49c552)]: Optimize association cache, only cacheable association use ArCache query now.
22
+ [Compare [#4328f38..4ec14e9](https://github.com/OuYangJinTing/ar_cache/compare/4328f38..4ec14e9)]:
23
+
24
+ - Optimize association cache, only cacheable association use ArCache query now.
15
25
 
16
26
  ## 1.2.0 (2021-03-12 UTC)
17
27
 
18
- [Commit [#c830907](https://github.com/OuYangJinTing/ar_cache/commit/c830907595b7d1d46a2f29204ee6051ecc3ff30c)]:
28
+ [Compare [#eb27f99..c830907](https://github.com/OuYangJinTing/ar_cache/compare/eb27f99..c830907)]:
19
29
 
20
30
  - Remove methods: `ArCache::MockTable#enabled?`, `ArCache::MockTable#select_enabled?`, `ArCache::Table.enabled?`, `ArCache::Table.select_enabled?`, `ActiveRecord::Relation#skip_ar_cache`.
21
31
  - Rename methods: `ArCache#skip_cache? => ArCache#skip?`, `ArCache#skip_cache => ArCache#skip`, `ArCache#pre_expire? => ArCache#expire?`, `ArCache#pre_expire => ArCache#expire`.
@@ -23,9 +33,11 @@
23
33
 
24
34
  ## 1.1.0 (2021-03-10 UTC)
25
35
 
26
- - [Commit [#92965d2](https://github.com/OuYangJinTing/ar_cache/commit/92965d26e130da9a13bd52ea31f3f668851f6f12)] Fully automatic delete cache when call delete_all/update_all method.
27
- - [Commit [#231cfd3](https://github.com/OuYangJinTing/ar_cache/commit/231cfd35c2c197bf41628f4f914ba39fb8debd81)] Optimize has_one(through:) cache implementation.
28
- - [Commit [#ce5444c](https://github.com/OuYangJinTing/ar_cache/commit/ce5444c8c4ec0a61bec5e07d694295d3cc5decf8)] ActiveRecord::Relation#reload and ActiveRecord::Associations::Association#reload should skip read cache if associated target is already loaded.
36
+ [Compare [#a15d5f5..ce5444c](https://github.com/OuYangJinTing/ar_cache/compare/a15d5f5...ce5444c)]:
37
+
38
+ - Fully automatic delete cache when call delete_all/update_all method.
39
+ - Optimize has_one(through:) cache implementation.
40
+ - ActiveRecord::Relation#reload and ActiveRecord::Associations::Association#reload should skip read cache if associated target is already loaded.
29
41
 
30
42
  ## 1.0.0 (2021-03-02 UTC)
31
43
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ar_cache (1.4.0)
4
+ ar_cache (1.5.0)
5
5
  activerecord (>= 6.1, < 7)
6
6
 
7
7
  GEM
@@ -147,8 +147,8 @@ GEM
147
147
  unicode-display_width (>= 1.4.0, < 3.0)
148
148
  rubocop-ast (1.4.1)
149
149
  parser (>= 2.7.1.5)
150
- rubocop-minitest (0.10.3)
151
- rubocop (>= 0.87, < 2.0)
150
+ rubocop-minitest (0.11.0)
151
+ rubocop (>= 0.90, < 2.0)
152
152
  rubocop-performance (1.10.1)
153
153
  rubocop (>= 0.90.0, < 2.0)
154
154
  rubocop-ast (>= 0.4.0)
@@ -15,7 +15,7 @@ module ArCache
15
15
  end
16
16
 
17
17
  if (owner.strict_loading? || reflection.strict_loading?) && owner.validation_context.nil?
18
- Base.strict_loading_violation!(owner: owner.class, reflection: reflection)
18
+ ::ActiveRecord::Base.strict_loading_violation!(owner: owner.class, reflection: reflection)
19
19
  end
20
20
 
21
21
  PRELOADER.preload(owner, reflection.name)
@@ -10,7 +10,7 @@ module ArCache
10
10
 
11
11
  def ar_cache_table
12
12
  @ar_cache_table ||= begin
13
- if abstract_class? || self == ArCache::Record
13
+ if abstract_class? || table_name == 'ar_cache_records'
14
14
  ArCache::MockTable
15
15
  else
16
16
  ArCache::Table.new(table_name)
@@ -4,7 +4,7 @@ require 'yaml'
4
4
 
5
5
  module ArCache
6
6
  class Configuration
7
- singleton_class.attr_accessor :disabled, :select_disabled, :expires_in, :read_uncommitted, :index_column_max_size
7
+ singleton_class.attr_accessor :disabled, :select_disabled, :expires_in, :read_uncommitted, :column_length
8
8
  singleton_class.attr_reader :cache_store, :tables_options, :coder
9
9
 
10
10
  def self.configure
@@ -53,6 +53,6 @@ module ArCache
53
53
  @select_disabled = true
54
54
  @expires_in = 604_800 # 1 week
55
55
  @read_uncommitted = false
56
- @index_column_max_size = 64
56
+ @column_length = 64
57
57
  end
58
58
  end
@@ -59,9 +59,9 @@ module ArCache
59
59
 
60
60
  private def detect_wrong_key(entry, where_values_hash)
61
61
  where_values_hash.detect do |k, v|
62
- value = entry[k]
63
- next if value.nil?
62
+ next unless entry.key?(k)
64
63
 
64
+ value = entry[k]
65
65
  if v.is_a?(Array)
66
66
  return k unless v.include?(value)
67
67
  else
@@ -66,7 +66,7 @@ module ArCache
66
66
  (@select_values - table.column_names).empty?
67
67
  end
68
68
 
69
- private def order_values_cacheable?
69
+ private def order_values_cacheable? # rubocop:disable Metrics/CyclomaticComplexity
70
70
  return true if where_clause.single?
71
71
 
72
72
  size = relation.order_values.size
@@ -81,6 +81,7 @@ module ArCache
81
81
  when String
82
82
  @order_name, @order_desc = first_order_value.downcase.split
83
83
  return false unless table.column_names.include?(@order_name)
84
+ return false unless ['asc', 'desc', nil].include?(@order_desc)
84
85
 
85
86
  @order_desc = @order_desc == 'desc'
86
87
  else
@@ -5,7 +5,7 @@ module ArCache
5
5
  self.table_name = 'ar_cache_records'
6
6
 
7
7
  def self.get(table_name)
8
- ArCache.skip { find_by(table_name: table_name) }
8
+ find_by(table_name: table_name)
9
9
  end
10
10
 
11
11
  def self.version(table)
@@ -101,14 +101,14 @@ module ArCache
101
101
  end
102
102
  end
103
103
 
104
- private def custom_unique_indexes(indexes)
104
+ private def custom_unique_indexes(indexes, columns)
105
105
  indexes.each do |index|
106
- index.each do |column|
107
- column = columns.find { |c| c.name == column }
108
- raise ArgumentError, "The #{name} table not found #{column.inspect} column" if column.nil?
106
+ index.each do |field|
107
+ column = columns.find { |c| c.name == field }
108
+ raise ArgumentError, "The #{name} table not found #{field.inspect} column" if column.nil?
109
109
 
110
110
  if column.type == :datetime
111
- raise ArgumentError, "The #{column.inspect} is datetime type, ArCache do't support datetime type"
111
+ raise ArgumentError, "The #{field.inspect} is datetime type, ArCache do't support datetime type"
112
112
  end
113
113
  end
114
114
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ArCache
4
- VERSION = '1.4.0'
4
+ VERSION = '1.5.0'
5
5
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module ArCache
4
4
  class WhereClause
5
- attr_reader :klass, :table, :predicates
5
+ attr_reader :klass, :table, :predicates, :invalid_keys
6
6
 
7
7
  def initialize(klass, predicates)
8
8
  @klass = klass
@@ -105,7 +105,7 @@ module ArCache
105
105
 
106
106
  name = node.left.name.to_s
107
107
  value = extract_node_value(node.right)
108
- next if value.respond_to?(:size) && value.size > ArCache::Configuration.index_column_max_size
108
+ next if value.respond_to?(:size) && value.size > ArCache::Configuration.column_length
109
109
 
110
110
  hash[name] = value
111
111
  end
@@ -14,7 +14,7 @@ ArCache.configure do |config|
14
14
  # config.coder = [YAML|JSON] # default YAML
15
15
 
16
16
  # Support the maximum length of index column value.
17
- # config.index_column_max_size = Integer # default 64
17
+ # config.column_length = Integer # default 64
18
18
 
19
19
  # ArCache switch.
20
20
  # config.disabled = Boolean # default false
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ar_cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - OuYangJinTing
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-15 00:00:00.000000000 Z
11
+ date: 2021-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord