Skip to content

Commit

Permalink
Revalidate connection in RedisClient#connected?
Browse files Browse the repository at this point in the history
Otherwise if it has pending reads it will be closed when
used anyway.
  • Loading branch information
byroot committed Dec 7, 2023
1 parent 8a3dafd commit 2106ae2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Unreleased

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

# 0.18.0
Expand Down
9 changes: 5 additions & 4 deletions lib/redis_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -222,17 +222,18 @@ def with(_options = nil)

def timeout=(timeout)
super
raw_connection.read_timeout = raw_connection.write_timeout = timeout if connected?
@raw_connection&.read_timeout = timeout
@raw_connection&.write_timeout = timeout
end

def read_timeout=(timeout)
super
raw_connection.read_timeout = timeout if connected?
@raw_connection&.read_timeout = timeout
end

def write_timeout=(timeout)
super
raw_connection.write_timeout = timeout if connected?
@raw_connection&.write_timeout = timeout
end

def pubsub
Expand Down Expand Up @@ -386,7 +387,7 @@ def zscan(key, *args, **kwargs, &block)
end

def connected?
@raw_connection&.connected?
@raw_connection&.revalidate
end

def close
Expand Down

0 comments on commit 2106ae2

Please sign in to comment.