void IConfigurationSettingHostService.Attach(IConfigurationSettingItem setting) { this.setting = (RedisCacheSetting)setting; options = new ConfigurationOptions { DefaultDatabase = this.setting.DefaultDb, Password = this.setting.Password, AllowAdmin = true }; var endPoints = new EndPointCollection(); foreach (var h in this.setting.Hosts) { if (h.Port == 0) { options.EndPoints.Add(h.Server); } else { options.EndPoints.Add(h.Server, h.Port); } } }
void IConfigurationSettingHostService.Attach(IConfigurationSettingItem setting) { this.setting = (RedisCacheSetting)setting; if (!string.IsNullOrEmpty(this.setting.ConnectionString)) { options = ConfigurationOptions.Parse(this.setting.ConnectionString); } else { options = new ConfigurationOptions { DefaultDatabase = this.setting.DefaultDb, Password = this.setting.Password, ConnectTimeout = this.setting.ConnectTimeout, AllowAdmin = true, Proxy = this.setting.Twemproxy ? Proxy.Twemproxy : Proxy.None }; foreach (var host in this.setting.Hosts) { if (host.Port == 0) { options.EndPoints.Add(host.Server); } else { options.EndPoints.Add(host.Server, host.Port); } } } }
public IConfigurationSettingItem Parse(System.Xml.XmlNode section) { var setting = new RedisCacheSetting(); setting.Name = section.GetAttributeValue("name"); setting.CacheType = Type.GetType(section.GetAttributeValue("type"), false, true); var configNode = section.SelectSingleNode("config"); if (configNode != null) { var serializerType = configNode.GetAttributeValue("serializerType"); if (!string.IsNullOrEmpty(serializerType)) { setting.SerializerType = serializerType.ParseType(); } setting.MaxReadPoolSize = configNode.GetAttributeValue("maxReadPoolSize", 5); setting.MaxWritePoolSize = configNode.GetAttributeValue("maxWritePoolSize", 5); setting.DefaultDb = configNode.GetAttributeValue("defaultDb", 0); setting.Password = configNode.GetAttributeValue("password"); foreach (XmlNode nd in configNode.SelectNodes("host")) { var host = new RedisCacheHost(); host.Server = nd.GetAttributeValue("server"); host.Port = nd.GetAttributeValue("port", 0); host.ReadOnly = nd.GetAttributeValue("readonly", false); setting.Hosts.Add(host); } } return(setting); }
public IConfigurationSettingItem Parse(IConfiguration configuration) { var setting = new RedisCacheSetting(); setting.CacheType = Type.GetType(configuration["type"], false, true); var configNode = configuration.GetSection("config"); if (configNode.Exists()) { var serializerType = configNode["serializerType"]; if (!string.IsNullOrEmpty(serializerType)) { setting.SerializerType = serializerType.ParseType(); } setting.MaxReadPoolSize = configNode["maxReadPoolSize"].To(5); setting.MaxWritePoolSize = configNode["maxWritePoolSize"].To(5); setting.DefaultDb = configNode["defaultDb"].To(0); setting.Password = configNode["password"]; foreach (var nd in configNode.GetSection("host").GetChildren()) { var host = new RedisCacheHost(); host.Server = nd["server"]; host.Port = nd["port"].To(0); host.ReadOnly = nd["readonly"].To(false); setting.Hosts.Add(host); } } return(setting); }
void IConfigurationSettingHostService.Attach(IConfigurationSettingItem setting) { this.setting = (RedisCacheSetting)setting; if (this.setting.SerializerType != null) { serializer = this.setting.SerializerType.New <ObjectSerializer>(); } else { serializer = new ObjectSerializer(); } var hosts = new List <string>(); var readHosts = new List <string>(); foreach (var h in this.setting.Hosts) { var address = h.EndPoint; if (!string.IsNullOrEmpty(h.Password)) { address = h.Password + "@" + address; } hosts.Add(address); if (h.ReadOnly) { readHosts.Add(address); } } manager = new PooledRedisClientManager(hosts.ToArray(), readHosts.ToArray(), new RedisClientManagerConfig { MaxReadPoolSize = this.setting.MaxReadPoolSize, MaxWritePoolSize = this.setting.MaxWritePoolSize, DefaultDb = this.setting.DefaultDb }); }