Beispiel #1
0
 /// <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)
     : this(readWriteHosts, readOnlyHosts, config, null, null, null)
 {
 }
Beispiel #2
0
        public PooledRedisClientManager(
            IEnumerable <string> readWriteHosts,
            IEnumerable <string> readOnlyHosts,
            RedisClientManagerConfig config,
            long?initalDb,
            int?poolSizeMultiplier,
            int?poolTimeOutSeconds)
        {
            this.Db = config != null
                ? config.DefaultDb ?? initalDb
                : initalDb;

            var masters = (readWriteHosts ?? new string[0]).ToArray();
            var slaves  = (readOnlyHosts ?? new string[0]).ToArray();

            RedisResolver = new RedisResolver(masters, slaves);

            this.PoolSizeMultiplier = poolSizeMultiplier ?? 10;

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

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

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

            JsConfig.InitStatics();

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