ar_cache 2.1.0 → 2.2.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: 2d9f5ff76912fe1e2276c795f619cf2e1e88780e7592e7fcb659e55a75bd8aff
4
- data.tar.gz: 51ccc09d008c7d345dc9901c2898463ef5d2ebd40649b829b63ba801b13948da
3
+ metadata.gz: d800437be2b2e54b404da4d9361b5c36e0b25b430d786e83e4730ddbe4103e24
4
+ data.tar.gz: 0eb12fd4754c4668bb8357579110104c161cda154836630f258acfa19cc5b5ad
5
5
  SHA512:
6
- metadata.gz: f8422672824015d7496620282919ff08b380066c8e05d8bde53bd8ef732f6b3a1c475f86bdd258f188be151fd78734b79bddbfa00bb20ce9b78be4443e96a168
7
- data.tar.gz: 3059b104bf49417391e3edb84c5005822ba652b8c29bf8fd0de7c23080444fbd8345da5776a8bd0ba81b515845e567776c22b0a925c0235042c7383f4610cbc6
6
+ metadata.gz: 9fbc2c60ca0e74d158428aa7fe055b47b52528ff6a4ea8ebd59e5e333193302d0c08170a78b70203b018a47a7752d59d4d1f7d1faa7a867a46c47c760000809c
7
+ data.tar.gz: f751713b8480b698ebb8aef0b5ebbd082b4968700ba00763f3e1f623bdc2a54deb71bd6b5635da04768498b2772c9f95b8b31c12420fbe90265ef4b2862f3425
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## main
4
4
 
5
+ ## 2.2.0 (2018-08-09 UTC)
6
+
7
+ - [PR [#5](https://github.com/OuYangJinTing/ar_cache/pull/5)] Fix should query database if exists table transaction ([@OuYangJinTing](https://github.com/OuYangJinTing))
8
+
5
9
  ## 2.1.0 (2018-06-29 UTC)
6
10
 
7
11
  - [PR [#4](https://github.com/OuYangJinTing/ar_cache/pull/4)] Fix high concurrency causes write dirty cache ([@OuYangJinTing](https://github.com/OuYangJinTing))
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ar_cache (2.1.0)
4
+ ar_cache (2.2.0)
5
5
  activerecord (>= 6.1, < 7)
6
6
  oj (>= 3, < 4)
7
7
 
@@ -20,9 +20,20 @@ module ArCache
20
20
  result
21
21
  end
22
22
 
23
- # def insert(arel, ...)
24
- # end
25
- # alias create insert
23
+ def insert(arel, ...)
24
+ super.tap do
25
+ if arel.is_a?(String)
26
+ sql = arel.downcase
27
+
28
+ ArCache::Table.all.each do |table|
29
+ transaction_manager.add_transaction_table(table.name) if sql.include?(table.name)
30
+ end
31
+ else
32
+ transaction_manager.add_transaction_table(arel.ast.relation.name)
33
+ end
34
+ end
35
+ end
36
+ alias create insert
26
37
 
27
38
  def update(arel, ...)
28
39
  super.tap { |num| update_ar_cache(arel) unless num.zero? }
@@ -73,7 +73,7 @@ module ArCache
73
73
  end
74
74
 
75
75
  def add_transaction_table(table_name)
76
- @transaction_tables[table_name] = true if fully_joinable?
76
+ @transaction_tables[table_name] = true if fully_joinable? && @stack.any?
77
77
  end
78
78
 
79
79
  def transaction_table?(table_name)
@@ -5,7 +5,11 @@ module ArCache
5
5
  module InsertAll
6
6
  def execute
7
7
  super.tap do
8
- connection.current_transaction.update_ar_cache_table(model.ar_cache_table) if on_duplicate == :update
8
+ if on_duplicate == :update
9
+ connection.current_transaction.update_ar_cache_table(model.ar_cache_table)
10
+ else # insert
11
+ connection.transaction_manager.add_transaction_table(model.table_name)
12
+ end
9
13
  end
10
14
  end
11
15
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ArCache
4
- VERSION = '2.1.0'
4
+ VERSION = '2.2.0'
5
5
  end
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: 2.1.0
4
+ version: 2.2.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-06-29 00:00:00.000000000 Z
11
+ date: 2021-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord