distribute_reads 0.4.0 → 0.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: 3b3c66d675a295bdde2d0dcc05590ed3af790a8a44718b2044fb6482c3330836
4
- data.tar.gz: 63db83095a8dcadfec723451c89afc9e3f712cef35a01d610b87f308febaa37c
3
+ metadata.gz: 498115398e131f837029f3ad86c21ea646204b399f732a800b32687135bee154
4
+ data.tar.gz: 40c983fa023cab9fe00b5f0e7b03925d2f1d7c6e3d30056a26e9c147fd92d4b4
5
5
  SHA512:
6
- metadata.gz: 0ce34129b83a7e5e5511dd96e5590d6bf80333124290591e94fc2db6291b45979f5dfd4467d2f81c1be4040cab55e451db9c41e318a1aa3285b94802e52c0244
7
- data.tar.gz: 725b782d62ad8521407a1fd0b3c4a634e09147c83cb40f150cc04bc0ca64f1ac18565e9cfdb24966cf1296b1e4cd30388a8568ec83d84e5fccb1c1d2ce7e7ee7
6
+ metadata.gz: 3a3a60620721ef9b23d1faf8a742386dfd58d3830ee7b110dbc44d100d7fd7670189e8893f1d21eab4d7bced008942f8fe8116756ae1aae6cec0f9427b3018d4
7
+ data.tar.gz: 56b65735bffb296bcfc8719c847988c0ecc4610c21ecad650115181431ac85b0b7cd686c7a409cede3cfc25c9a54de74e6f053556ea9ca6c28feb242e6ad1709
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.5.0 (2024-06-24)
2
+
3
+ - Dropped support for Makara 0.4
4
+ - Dropped support for Ruby < 3.1 and Active Record < 6.1
5
+
1
6
  ## 0.4.0 (2022-12-28)
2
7
 
3
8
  - Made `distribute_reads` method private to behave like `Kernel` methods
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2017-2022 Andrew Kane
1
+ Copyright (c) 2017-2024 Andrew Kane
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -4,7 +4,7 @@ Scale database reads to replicas in Rails
4
4
 
5
5
  :tangerine: Battle-tested at [Instacart](https://www.instacart.com/opensource)
6
6
 
7
- [![Build Status](https://github.com/ankane/distribute_reads/workflows/build/badge.svg?branch=master)](https://github.com/ankane/distribute_reads/actions)
7
+ [![Build Status](https://github.com/ankane/distribute_reads/actions/workflows/build.yml/badge.svg)](https://github.com/ankane/distribute_reads/actions)
8
8
 
9
9
  ## Installation
10
10
 
@@ -74,7 +74,7 @@ You can pass any options as well.
74
74
 
75
75
  ## Lazy Evaluation
76
76
 
77
- ActiveRecord uses [lazy evaluation](https://www.theodinproject.com/courses/ruby-on-rails/lessons/active-record-queries), which can delay the execution of a query to outside of a `distribute_reads` block. In this case, the primary will be used.
77
+ Active Record uses [lazy evaluation](https://www.theodinproject.com/courses/ruby-on-rails/lessons/active-record-queries), which can delay the execution of a query to outside of a `distribute_reads` block. In this case, the primary will be used.
78
78
 
79
79
  ```ruby
80
80
  users = distribute_reads { User.where(orders_count: 1) } # not executed yet
@@ -185,9 +185,9 @@ distribute_reads(replica: true) do
185
185
  end
186
186
  ```
187
187
 
188
- ## Rails 6
188
+ ## Rails
189
189
 
190
- Rails 6 has [native support for replicas](https://guides.rubyonrails.org/active_record_multiple_databases.html) :tada:
190
+ Rails 6+ has [native support for replicas](https://guides.rubyonrails.org/active_record_multiple_databases.html) :tada:
191
191
 
192
192
  ```ruby
193
193
  ActiveRecord::Base.connected_to(role: :reading) do
@@ -195,11 +195,11 @@ ActiveRecord::Base.connected_to(role: :reading) do
195
195
  end
196
196
  ```
197
197
 
198
- However, it’s not able to automatically route queries like Makara just yet.
198
+ However, it’s not able to do automatic statement-based routing like Makara yet.
199
199
 
200
200
  ## Thanks
201
201
 
202
- Thanks to [TaskRabbit](https://github.com/taskrabbit) for Makara, [Sherin Kurian](https://github.com/sherinkurian) for the max lag option, and [Nick Elser](https://github.com/nickelser) for the write-through cache.
202
+ Thanks to [TaskRabbit](https://github.com/taskrabbit) for Makara, [Sherin Kurian](https://github.com/sherin) for the max lag option, and [Nick Elser](https://github.com/nickelser) for the write-through cache.
203
203
 
204
204
  ## History
205
205
 
@@ -1,3 +1,3 @@
1
1
  module DistributeReads
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -3,10 +3,9 @@ require "active_support"
3
3
  require "makara"
4
4
 
5
5
  # modules
6
- require "distribute_reads/appropriate_pool"
7
- require "distribute_reads/cache_store"
8
- require "distribute_reads/global_methods"
9
- require "distribute_reads/version"
6
+ require_relative "distribute_reads/appropriate_pool"
7
+ require_relative "distribute_reads/global_methods"
8
+ require_relative "distribute_reads/version"
10
9
 
11
10
  module DistributeReads
12
11
  class Error < StandardError; end
@@ -164,6 +163,6 @@ Object.include DistributeReads::GlobalMethods
164
163
  Object.send :private, :distribute_reads
165
164
 
166
165
  ActiveSupport.on_load(:active_job) do
167
- require "distribute_reads/job_methods"
166
+ require_relative "distribute_reads/job_methods"
168
167
  include DistributeReads::JobMethods
169
168
  end
metadata CHANGED
@@ -1,29 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: distribute_reads
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-28 00:00:00.000000000 Z
11
+ date: 2024-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activerecord
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '6.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '6.1'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: makara
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
31
  - - ">="
18
32
  - !ruby/object:Gem::Version
19
- version: '0.4'
33
+ version: '0.5'
20
34
  type: :runtime
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
38
  - - ">="
25
39
  - !ruby/object:Gem::Version
26
- version: '0.4'
40
+ version: '0.5'
27
41
  description:
28
42
  email: andrew@ankane.org
29
43
  executables: []
@@ -35,7 +49,6 @@ files:
35
49
  - README.md
36
50
  - lib/distribute_reads.rb
37
51
  - lib/distribute_reads/appropriate_pool.rb
38
- - lib/distribute_reads/cache_store.rb
39
52
  - lib/distribute_reads/global_methods.rb
40
53
  - lib/distribute_reads/job_methods.rb
41
54
  - lib/distribute_reads/version.rb
@@ -51,14 +64,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
51
64
  requirements:
52
65
  - - ">="
53
66
  - !ruby/object:Gem::Version
54
- version: '2.6'
67
+ version: '3.1'
55
68
  required_rubygems_version: !ruby/object:Gem::Requirement
56
69
  requirements:
57
70
  - - ">="
58
71
  - !ruby/object:Gem::Version
59
72
  version: '0'
60
73
  requirements: []
61
- rubygems_version: 3.4.1
74
+ rubygems_version: 3.5.11
62
75
  signing_key:
63
76
  specification_version: 4
64
77
  summary: Scale database reads with replicas in Rails
@@ -1,29 +0,0 @@
1
- module DistributeReads
2
- class CacheStore
3
- def read(key)
4
- memory_cached = memory_store.read(key)
5
- return nil if memory_cached == :nil
6
- return memory_cached if memory_cached
7
-
8
- store_cached = store.try(:read, key)
9
- memory_store.write(key, store_cached || :nil)
10
- store_cached
11
- end
12
-
13
- def write(*args)
14
- memory_store.write(*args)
15
- store.try(:write, *args)
16
- end
17
-
18
- private
19
-
20
- # use ActiveSupport::Cache::MemoryStore instead?
21
- def memory_store
22
- @memory_store ||= Makara::Cache::MemoryStore.new
23
- end
24
-
25
- def store
26
- @store ||= Rails.cache
27
- end
28
- end
29
- end