fresh_connection 2.3.1 → 2.3.2

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
  SHA1:
3
- metadata.gz: deb0b581ea9aecc3c27b3d32a6a14c93ee3a543f
4
- data.tar.gz: 0323e5cd09c34895529a49d339c00797c45cfa07
3
+ metadata.gz: 0d6bb81775c1ffa074f52f58fad152f9d02d8498
4
+ data.tar.gz: 622671bc7d23b5a88f92eb8f4430b5b15014d917
5
5
  SHA512:
6
- metadata.gz: 5163c26ac8a920f5b5f3485d4049b147ae826075ba8cfb6c2b1f6adf2b3e9966c046304932851c2b0b64228892c08569c2b5d81d7ef0bd21ae5db025e2f28bbc
7
- data.tar.gz: 71e16efe75624fd56cf02374bb8db2fa5e94c3038c3b044dbb8df1ba689ed797f1e5254bb65fd31a9d4276125c876f13edb3db4d5dc8142ce002ae5ec18f125d
6
+ metadata.gz: 6a7de0aff8b2b35291005f1236bf5e6d87e4285a5d54b6619eebebf2a1edc5a83f750abfcc2795ee070edc7c97d4aec2796d5e5f3622d7293bdfab58ab829cdb
7
+ data.tar.gz: 3799709992b9fbd0cb4c8cac11db8db34601fec8333dbe41bd25c51eeddadec36f5153a9fc39aa5548e373e8175e938760e471d11bae77edb04aecb63d63891b
@@ -3,12 +3,62 @@ module FreshConnection
3
3
  module ArAbstractAdapter
4
4
  def self.prepended(base)
5
5
  base.send :attr_writer, :replica_group
6
+ base.send :attr_accessor, :master_connection
6
7
  end
7
8
 
8
9
  def log(*args)
9
10
  args[1] = "[#{@replica_group}] #{args[1]}" if defined?(@replica_group)
10
11
  super
11
12
  end
13
+
14
+ def query_cache
15
+ return @query_cache unless master_connection
16
+ master_connection.query_cache
17
+ end
18
+
19
+ def query_cache_enabled
20
+ return @query_cache_enabled unless master_connection
21
+ master_connection.query_cache_enabled
22
+ end
23
+
24
+ def cache(&block)
25
+ return super unless master_connection
26
+ master_connection.cache(&block)
27
+ end
28
+
29
+ def enable_query_cache!
30
+ return super unless master_connection
31
+ master_connection.enable_query_cache!
32
+ end
33
+
34
+ def disable_query_cache!
35
+ return super unless master_connection
36
+ master_connection.disable_query_cache!
37
+ end
38
+
39
+ def uncached(&block)
40
+ return super unless master_connection
41
+ master_connection.uncached(&block)
42
+ end
43
+
44
+ def clear_query_cache
45
+ return super unless master_connection
46
+ master_conection.clear_query_cache
47
+ end
48
+
49
+ def select_all(*args)
50
+ return super unless master_connection
51
+ @query_cache_enabled = master_connection.query_cache_enabled
52
+ super
53
+ end
54
+
55
+ private
56
+
57
+ def cache_sql(*args)
58
+ return super unless master_connection
59
+ @query_cache = master_connection.query_cache
60
+ super
61
+ end
12
62
  end
13
63
  end
14
64
  end
@@ -6,15 +6,13 @@ module FreshConnection
6
6
  module Extend
7
7
  module ArBase
8
8
  def connection
9
- if FreshConnection::AccessControl.replica_access?
10
- if logger && logger.debug?
11
- replica_connection.tap{|c| c.replica_group = replica_group }
12
- else
13
- replica_connection
14
- end
15
- else
16
- super
17
- end
9
+ master_c = super
10
+ return master_c unless FreshConnection::AccessControl.replica_access?
11
+
12
+ replica_c = replica_connection
13
+ replica_c.master_connection = master_c
14
+ replica_c.replica_group = replica_group if logger && logger.debug?
15
+ replica_c
18
16
  end
19
17
 
20
18
  def read_master
@@ -1,4 +1,4 @@
1
1
  module FreshConnection
2
- VERSION = "2.3.1"
2
+ VERSION = "2.3.2"
3
3
  end
4
4
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fresh_connection
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 2.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tsukasa OISHI
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-12 00:00:00.000000000 Z
11
+ date: 2017-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -246,7 +246,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
246
246
  version: '0'
247
247
  requirements: []
248
248
  rubyforge_project:
249
- rubygems_version: 2.5.2
249
+ rubygems_version: 2.4.5.1
250
250
  signing_key:
251
251
  specification_version: 4
252
252
  summary: FreshConnection supports connections with configured replica servers.