Skip to content

Commit 2106ae2

Browse files
committed
Revalidate connection in RedisClient#connected?
Otherwise if it has pending reads it will be closed when used anyway.
1 parent 8a3dafd commit 2106ae2

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Unreleased
22

3+
- Revalidate connection in `RedisClient#connected?`
34
- Eagerly fail if `db:` isn't an Integer. #151.
45

56
# 0.18.0

lib/redis_client.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,17 +222,18 @@ def with(_options = nil)
222222

223223
def timeout=(timeout)
224224
super
225-
raw_connection.read_timeout = raw_connection.write_timeout = timeout if connected?
225+
@raw_connection&.read_timeout = timeout
226+
@raw_connection&.write_timeout = timeout
226227
end
227228

228229
def read_timeout=(timeout)
229230
super
230-
raw_connection.read_timeout = timeout if connected?
231+
@raw_connection&.read_timeout = timeout
231232
end
232233

233234
def write_timeout=(timeout)
234235
super
235-
raw_connection.write_timeout = timeout if connected?
236+
@raw_connection&.write_timeout = timeout
236237
end
237238

238239
def pubsub
@@ -386,7 +387,7 @@ def zscan(key, *args, **kwargs, &block)
386387
end
387388

388389
def connected?
389-
@raw_connection&.connected?
390+
@raw_connection&.revalidate
390391
end
391392

392393
def close

0 commit comments

Comments
 (0)