amakawa / redic

Lightweight Redis Client
MIT License
120 stars 14 forks source link

Allow timeout to be changed #13

Closed scalp42 closed 5 years ago

scalp42 commented 5 years ago

Hi @soveran,

Thank you for all your contributions in the Redis world 🙇

This is a simple PR that allows changing the timeout of the Redic object, without creating a new object or using instance_variable_set hacks as seen in https://github.com/soveran/redisent/issues/1

Before:

require 'redic'

redic = Redic.new(url = 'redis://127.0.0.1:6379', timeout= 1_000)

redic.timeout
# => 1000

redic.instance_variable_get('@client').instance_variable_set('@timeout', 42)

redic.timeout
# => 42

redic.client.timeout
# => 42

After:

require 'redic'

redic = Redic.new(url = 'redis://127.0.0.1:6379', timeout= 1_000)

redic.timeout
# => 1000

redic.timeout = 42 # same as redic.client.timeout = 42

redic.timeout
# => 42

redic.client.timeout
# => 42

Let me know, thanks for looking at it ✌️

soveran commented 5 years ago

@scalp42 Good idea :-) I will release it later today after reviewing the other issues. Thanks a lot!

soveran commented 5 years ago

This was released in version 1.5.1. Thanks!