ar_cache 1.4.0 → 1.5.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 +18 -6
- data/Gemfile.lock +3 -3
- data/lib/ar_cache/active_record/associations/has_one_through_association.rb +1 -1
- data/lib/ar_cache/active_record/model_schema.rb +1 -1
- data/lib/ar_cache/configuration.rb +2 -2
- data/lib/ar_cache/marshal.rb +2 -2
- data/lib/ar_cache/query.rb +2 -1
- data/lib/ar_cache/record.rb +1 -1
- data/lib/ar_cache/table.rb +5 -5
- data/lib/ar_cache/version.rb +1 -1
- data/lib/ar_cache/where_clause.rb +2 -2
- data/lib/generators/ar_cache/templates/configuration.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86d921c69c8ac7d8cbc0cefdb5614120a60f5663c5a2b8e3bc07a1c9c1d8d8a0
|
4
|
+
data.tar.gz: ced6d5cf673fb6e83070ba95e4daf6fb9d0994a93f8963de63692317c9c77081
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
[
|
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
|
-
|
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
|
-
[
|
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
|
-
|
27
|
-
|
28
|
-
-
|
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
|
+
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.
|
151
|
-
rubocop (>= 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)
|
@@ -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, :
|
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
|
-
@
|
56
|
+
@column_length = 64
|
57
57
|
end
|
58
58
|
end
|
data/lib/ar_cache/marshal.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/ar_cache/query.rb
CHANGED
@@ -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
|
data/lib/ar_cache/record.rb
CHANGED
data/lib/ar_cache/table.rb
CHANGED
@@ -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 |
|
107
|
-
column = columns.find { |c| c.name ==
|
108
|
-
raise ArgumentError, "The #{name} table not found #{
|
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 #{
|
111
|
+
raise ArgumentError, "The #{field.inspect} is datetime type, ArCache do't support datetime type"
|
112
112
|
end
|
113
113
|
end
|
114
114
|
end
|
data/lib/ar_cache/version.rb
CHANGED
@@ -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.
|
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.
|
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
|
+
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-
|
11
|
+
date: 2021-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|