redis-client 0.8.1 → 0.9.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 +4 -4
- data/CHANGELOG.md +5 -1
- data/Gemfile.lock +1 -1
- data/README.md +0 -9
- data/lib/redis_client/config.rb +3 -1
- data/lib/redis_client/version.rb +1 -1
- data/lib/redis_client.rb +6 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95dd96eda7210df59b85fafb8d2df5fa46cf0d3d2da10ad1ebf60137b8ec2652
|
4
|
+
data.tar.gz: d417951e19d9a20b7f96a2d4e520d433cd52c38209d8c46499ddfc0d6d4be941
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0dd66a81c969a08abbb89140187e6a3a31aadcb258845082bf84bba792304ebc3d27852635fa4519805139eeecb7f405033b2b0c6acc4d39f7823873cd91dbdc
|
7
|
+
data.tar.gz: 4a9f5b79ffc8d195a3fac2cd439750d43124bb78583eef840564262d25565b2e585d8d77eb3f9d2096ec938fa4db7fe7a775c5ba5f80c4e2bd91f2b121901a98
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
# Unreleased
|
2
2
|
|
3
|
+
# 0.9.0
|
4
|
+
|
5
|
+
- Automatically reconnect if the process was forked.
|
6
|
+
|
3
7
|
# 0.8.1
|
4
8
|
|
5
|
-
- Make the client resilient to `Timeout.timeout` or `Thread#kill` use (it still
|
9
|
+
- Make the client resilient to `Timeout.timeout` or `Thread#kill` use (it still is very much discouraged to use either).
|
6
10
|
Use of async interrupts could cause responses to be interleaved.
|
7
11
|
- hiredis: handle commands returning a top-level `false` (no command does this today, but some extensions might).
|
8
12
|
- Workaround a bug in Ruby 2.6 causing a crash if the `debug` gem is enabled when `redis-client` is being required. Fix: #48
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -437,15 +437,6 @@ Contrary to the `redis` gem, `redis-client` doesn't protect against concurrent a
|
|
437
437
|
To use `redis-client` in concurrent environments, you MUST use a connection pool, or
|
438
438
|
have one client per Thread or Fiber.
|
439
439
|
|
440
|
-
### Fork Safety
|
441
|
-
|
442
|
-
`redis-client` doesn't try to detect forked processes. You MUST disconnect all clients before forking your process.
|
443
|
-
|
444
|
-
```ruby
|
445
|
-
redis.close
|
446
|
-
Process.fork ...
|
447
|
-
```
|
448
|
-
|
449
440
|
## Development
|
450
441
|
|
451
442
|
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/redis_client/config.rb
CHANGED
@@ -12,7 +12,7 @@ class RedisClient
|
|
12
12
|
DEFAULT_DB = 0
|
13
13
|
|
14
14
|
module Common
|
15
|
-
attr_reader :db, :password, :id, :ssl, :ssl_params, :command_builder,
|
15
|
+
attr_reader :db, :password, :id, :ssl, :ssl_params, :command_builder, :inherit_socket,
|
16
16
|
:connect_timeout, :read_timeout, :write_timeout, :driver, :connection_prelude, :protocol
|
17
17
|
|
18
18
|
alias_method :ssl?, :ssl
|
@@ -32,6 +32,7 @@ class RedisClient
|
|
32
32
|
protocol: 3,
|
33
33
|
client_implementation: RedisClient,
|
34
34
|
command_builder: CommandBuilder,
|
35
|
+
inherit_socket: false,
|
35
36
|
reconnect_attempts: false
|
36
37
|
)
|
37
38
|
@username = username
|
@@ -54,6 +55,7 @@ class RedisClient
|
|
54
55
|
end
|
55
56
|
|
56
57
|
@command_builder = command_builder
|
58
|
+
@inherit_socket = inherit_socket
|
57
59
|
|
58
60
|
reconnect_attempts = Array.new(reconnect_attempts, 0).freeze if reconnect_attempts.is_a?(Integer)
|
59
61
|
@reconnect_attempts = reconnect_attempts
|
data/lib/redis_client/version.rb
CHANGED
data/lib/redis_client.rb
CHANGED
@@ -67,6 +67,7 @@ class RedisClient
|
|
67
67
|
@read_timeout = read_timeout
|
68
68
|
@write_timeout = write_timeout
|
69
69
|
@command_builder = config.command_builder
|
70
|
+
@pid = Process.pid
|
70
71
|
end
|
71
72
|
|
72
73
|
def timeout=(timeout)
|
@@ -416,7 +417,7 @@ class RedisClient
|
|
416
417
|
end
|
417
418
|
|
418
419
|
def close
|
419
|
-
raw_connection&.close
|
420
|
+
@raw_connection&.close
|
420
421
|
@raw_connection = nil
|
421
422
|
self
|
422
423
|
end
|
@@ -597,6 +598,8 @@ class RedisClient
|
|
597
598
|
end
|
598
599
|
|
599
600
|
def ensure_connected(retryable: true)
|
601
|
+
close if !config.inherit_socket && @pid != Process.pid
|
602
|
+
|
600
603
|
if @disable_reconnection
|
601
604
|
if block_given?
|
602
605
|
yield @raw_connection
|
@@ -614,7 +617,6 @@ class RedisClient
|
|
614
617
|
connection
|
615
618
|
end
|
616
619
|
rescue ConnectionError, ProtocolError => error
|
617
|
-
connection&.close
|
618
620
|
close
|
619
621
|
|
620
622
|
if !@disable_reconnection && config.retry_connecting?(tries, error)
|
@@ -631,7 +633,6 @@ class RedisClient
|
|
631
633
|
@disable_reconnection = true
|
632
634
|
yield connection
|
633
635
|
rescue ConnectionError, ProtocolError
|
634
|
-
connection&.close
|
635
636
|
close
|
636
637
|
raise
|
637
638
|
ensure
|
@@ -646,6 +647,8 @@ class RedisClient
|
|
646
647
|
end
|
647
648
|
|
648
649
|
def connect
|
650
|
+
@pid = Process.pid
|
651
|
+
|
649
652
|
connection = Middlewares.connect(config) do
|
650
653
|
config.driver.new(
|
651
654
|
config,
|
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.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean Boussier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-09-
|
11
|
+
date: 2022-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: connection_pool
|