/// <summary>
 ///     Hosts can be an IP Address or Hostname in the format: host[:port]
 ///     e.g. 127.0.0.1:6379
 ///     default is: localhost:6379
 /// </summary>
 /// <param name="readWriteHosts" >The write hosts.</param>
 /// <param name="readOnlyHosts" >The read hosts.</param>
 /// <param name="config" >The config.</param>
 public PooledRedisClientManager(
     IEnumerable <string> readWriteHosts,
     IEnumerable <string> readOnlyHosts,
     RedisClientManagerConfig config = null)
     : this(readWriteHosts, readOnlyHosts, config, null, null, null)
 {
 }
        /// <inheritdoc />
        public PooledRedisClientManager(
            IEnumerable <string> readWriteHosts,
            IEnumerable <string> readOnlyHosts,
            RedisClientManagerConfig config,
            long?initialDb,
            int?poolSizeMultiplier,
            int?poolTimeoutSeconds)
        {
            this.Db = config != null
                ? config.DefaultDb ?? initialDb
                : initialDb;

            var masters = readWriteHosts?.ToArray() ?? Array.Empty <string>();
            var slaves  = readOnlyHosts?.ToArray() ?? Array.Empty <string>();

            this.RedisResolver = new RedisResolver(masters, slaves);

            this.PoolSizeMultiplier = poolSizeMultiplier ?? 20;

            this.Config = config ?? new RedisClientManagerConfig {
                MaxWritePoolSize = RedisConfig.DefaultMaxPoolSize ?? masters.Length * this.PoolSizeMultiplier,
                MaxReadPoolSize  = RedisConfig.DefaultMaxPoolSize ?? slaves.Length * this.PoolSizeMultiplier
            };

            this.OnFailover = new List <Action <IRedisClientManager> >();

            // if timeout provided, convert into milliseconds
            this.PoolTimeout = poolTimeoutSeconds != null
                ? poolTimeoutSeconds * 1000
                : 2000; // Default Timeout

            this.AssertAccessOnlyOnSameThread = RedisConfig.AssertAccessOnlyOnSameThread;

            if (this.Config.AutoStart)
            {
                this.OnStart();
            }
        }