redis-client 0.12.1 → 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: '0845ff9c4cbb2e63f1add455942b56eed1840abdd671e0d40aebb860bf6e8510'
4
- data.tar.gz: 2ac5ed7d4ff7762d715f17fa462a6f139c65ba0c0055f25718af968e941ff805
3
+ metadata.gz: f5e453ca140b38cff3f62e947e4168ca950117d1ff03562e5d6ed2bad0dbdd83
4
+ data.tar.gz: 8fe7edeb11051105d2505f95e6cda7360c2cf6a438b93e5bb0f775538456f28d
5
5
  SHA512:
6
- metadata.gz: 0e252e338aacc68a076fa2efe01d1bde4a74e25547c145670a979d0605ae022fc9a766e20ca765e7e2d4931298a7558fb154aed27d9d0c6ea5256238ac195d64
7
- data.tar.gz: 4f3f9da3836a2c0e587322aece7d7932b0968f2b9d99fa665d557e2647c3a9e8ac41fc82feb2317d3169d6ddc9349eefef82c579f4415e4c0749d6a9b78dec38
6
+ metadata.gz: 27596015912265226cd39b7c6e27fff214e096166121aa0e8dba0a0f81a7ba45663c0d28239e3610d57c3955ace8cfc1f428c4af8f9373b80bb196eeb89c61a8
7
+ data.tar.gz: 91b24e94e5332f4e74ca2dbb2e9adc60f7e8f9c5b698b1af5dfd5483bf836c95f6a79f39689272b742c6693ff8b6a6dd0d275e820f4a29f6d86b4dab650be6b4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Unreleased
2
2
 
3
+ # 0.12.2
4
+
5
+ - Cache calls to `Process.pid` on Ruby 3.1+. #91.
6
+
3
7
  # 0.12.1
4
8
 
5
9
  - Improve compatibility with `uri 0.12.0` (default in Ruby 3.2.0).
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- redis-client (0.12.1)
4
+ redis-client (0.12.2)
5
5
  connection_pool
6
6
 
7
7
  GEM
@@ -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.1"
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.1
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-16 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