redis-client 0.12.0 → 0.12.2

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: 398676851a40081cd70d1334fa845292b0df4b7036d6ae33d0fa3ae6fa7ee040
4
- data.tar.gz: 0a17e311c65180dcd67f106bcaca6e1f08a441e38e9ffdbab9876e2b3f62bc0a
3
+ metadata.gz: f5e453ca140b38cff3f62e947e4168ca950117d1ff03562e5d6ed2bad0dbdd83
4
+ data.tar.gz: 8fe7edeb11051105d2505f95e6cda7360c2cf6a438b93e5bb0f775538456f28d
5
5
  SHA512:
6
- metadata.gz: 196f490ad7632f4139099b6047c3973b8957be2df24a92f1ba9f5f7588360c2a89b04b487cd24251e4aabf6006bd51cece7429f9aeae75b9e5013cb00240bdfc
7
- data.tar.gz: bee6d01afc6805fa70720c09b213841d719a4bb045b6694d5a1d9c9efe6a5875c403464b7451d0d0a4d8056467440306936250cd6f537d47b45ee962dfa90658
6
+ metadata.gz: 27596015912265226cd39b7c6e27fff214e096166121aa0e8dba0a0f81a7ba45663c0d28239e3610d57c3955ace8cfc1f428c4af8f9373b80bb196eeb89c61a8
7
+ data.tar.gz: 91b24e94e5332f4e74ca2dbb2e9adc60f7e8f9c5b698b1af5dfd5483bf836c95f6a79f39689272b742c6693ff8b6a6dd0d275e820f4a29f6d86b4dab650be6b4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Unreleased
2
2
 
3
+ # 0.12.2
4
+
5
+ - Cache calls to `Process.pid` on Ruby 3.1+. #91.
6
+
7
+ # 0.12.1
8
+
9
+ - Improve compatibility with `uri 0.12.0` (default in Ruby 3.2.0).
10
+
3
11
  # 0.12.0
4
12
 
5
13
  - hiredis: fix a compilation issue on macOS and Ruby 3.2.0. See: #79
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- redis-client (0.12.0)
4
+ redis-client (0.12.2)
5
5
  connection_pool
6
6
 
7
7
  GEM
@@ -181,7 +181,15 @@ class RedisClient
181
181
 
182
182
  super(**kwargs)
183
183
 
184
- @host = host || uri&.host&.sub(/\A\[(.*)\]\z/, '\1') || DEFAULT_HOST
184
+ @host = host
185
+ unless @host
186
+ uri_host = uri&.host
187
+ uri_host = nil if uri_host&.empty?
188
+ if uri_host
189
+ @host = uri_host&.sub(/\A\[(.*)\]\z/, '\1')
190
+ end
191
+ end
192
+ @host ||= DEFAULT_HOST
185
193
  @port = Integer(port || uri&.port || DEFAULT_PORT)
186
194
  @path = path
187
195
  end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ class RedisClient
4
+ module PIDCache
5
+ if !Process.respond_to?(:fork) # JRuby or TruffleRuby
6
+ @pid = Process.pid
7
+ singleton_class.attr_reader(:pid)
8
+ elsif Process.respond_to?(:_fork) # Ruby 3.1+
9
+ class << self
10
+ attr_reader :pid
11
+
12
+ def update!
13
+ @pid = Process.pid
14
+ end
15
+ end
16
+ update!
17
+
18
+ module CoreExt
19
+ def _fork
20
+ child_pid = super
21
+ PIDCache.update! if child_pid == 0
22
+ child_pid
23
+ end
24
+ end
25
+ Process.singleton_class.prepend(CoreExt)
26
+ else # Ruby 3.0 or older
27
+ class << self
28
+ def pid
29
+ Process.pid
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class RedisClient
4
- VERSION = "0.12.0"
4
+ VERSION = "0.12.2"
5
5
  end
data/lib/redis_client.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  require "redis_client/version"
4
4
  require "redis_client/command_builder"
5
5
  require "redis_client/config"
6
+ require "redis_client/pid_cache"
6
7
  require "redis_client/sentinel_config"
7
8
  require "redis_client/middlewares"
8
9
 
@@ -67,7 +68,7 @@ class RedisClient
67
68
  @read_timeout = read_timeout
68
69
  @write_timeout = write_timeout
69
70
  @command_builder = config.command_builder
70
- @pid = Process.pid
71
+ @pid = PIDCache.pid
71
72
  end
72
73
 
73
74
  def timeout=(timeout)
@@ -609,7 +610,7 @@ class RedisClient
609
610
  end
610
611
 
611
612
  def ensure_connected(retryable: true)
612
- close if !config.inherit_socket && @pid != Process.pid
613
+ close if !config.inherit_socket && @pid != PIDCache.pid
613
614
 
614
615
  if @disable_reconnection
615
616
  if block_given?
@@ -658,7 +659,7 @@ class RedisClient
658
659
  end
659
660
 
660
661
  def connect
661
- @pid = Process.pid
662
+ @pid = PIDCache.pid
662
663
 
663
664
  connection = @middlewares.connect(config) do
664
665
  config.driver.new(
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.12.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean Boussier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-09 00:00:00.000000000 Z
11
+ date: 2023-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: connection_pool
@@ -45,6 +45,7 @@ files:
45
45
  - lib/redis_client/connection_mixin.rb
46
46
  - lib/redis_client/decorator.rb
47
47
  - lib/redis_client/middlewares.rb
48
+ - lib/redis_client/pid_cache.rb
48
49
  - lib/redis_client/pooled.rb
49
50
  - lib/redis_client/ruby_connection.rb
50
51
  - lib/redis_client/ruby_connection/buffered_io.rb