Namoshek / laravel-redis-sentinel

An extension of Laravels Redis driver which supports connecting to a Redis master through Redis Sentinel.
MIT License
20 stars 18 forks source link

Cast configuration values in code #43

Open Alhubing opened 4 days ago

Alhubing commented 4 days ago

Sorry for opening another issue regarding this topic. It would be nice if configuration values were casted in the code, instead of having to cast them manually in the configuration file.

Current configurations rely on auto casting, so current database values work with phpredis default driver but fails with this driver.

It fails when trying to connect to sentinel in PhpRedisSentinelConnector:

        $host = $config['sentinel_host'] ?? '';
        $port = (int)$config['sentinel_port'] ?? 26379;
        $timeout = (float)$config['sentinel_timeout'] ?? 0.2;
        $persistent = $config['sentinel_persistent'] ?? null;
        $retryInterval = (int)$config['sentinel_retry_interval'] ?? 0;
        $readTimeout = (int)$config['sentinel_read_timeout'] ?? 0;
        $username = $config['sentinel_username'] ?? '';
        $password = $config['sentinel_password'] ?? '';
        $ssl = $config['sentinel_ssl'] ?? null;

Casting these values, as you did in the README will be enough. This way you dont have to set all the casts in all you configuration files.

If you are ok with this i can submit the change.

Thank you.

Namoshek commented 4 days ago

Sure, send in a PR.