private IRedisClientsManager GetInstance(RedisClientManagerType type) { var manager = default(IRedisClientsManager); switch (type) { case RedisClientManagerType.News: var newsConfig = new RedisClientManagerConfig { MaxWritePoolSize = ConfigKeys.NEWS_MAX_WRITE_POOL_SIZE.ConfigValue().ToInt32(), MaxReadPoolSize = ConfigKeys.NEWS_MAX_READ_POOL_SIZE.ConfigValue().ToInt32(), AutoStart = true }; string[] newsReadWriteHosts = ConfigKeys.NEWS_REDIS_READ_WRITE_SERVERS.ConfigValue().Split(ASCII.SEMICOLON_CHAR); string[] newsReadOnlyHosts = ConfigKeys.NEWS_REDIS_READONLY_SERVERS.ConfigValue().Split(ASCII.SEMICOLON_CHAR); manager = new PooledRedisClientManager(newsReadWriteHosts, newsReadWriteHosts, newsConfig); break; case RedisClientManagerType.Theme: var themeConfig = new RedisClientManagerConfig { MaxWritePoolSize = ConfigKeys.THEME_MAX_WRITE_POOL_SIZE.ConfigValue().ToInt32(), MaxReadPoolSize = ConfigKeys.THEME_MAX_READ_POOL_SIZE.ConfigValue().ToInt32(), AutoStart = true }; string[] themeReadWriteHosts = ConfigKeys.THEME_REDIS_READ_WRITE_SERVERS.ConfigValue().Split(ASCII.SEMICOLON_CHAR); string[] themeRadOnlyHosts = ConfigKeys.THEME_REDIS_READONLY_SERVERS.ConfigValue().Split(ASCII.SEMICOLON_CHAR); manager = new PooledRedisClientManager(themeReadWriteHosts, themeReadWriteHosts, themeConfig); break; case RedisClientManagerType.Mixed: var mixedConfig = new RedisClientManagerConfig { MaxWritePoolSize = AppConfigKeys.MAX_WRITE_POOL_SIZE.ConfigValue().ToInt32(), MaxReadPoolSize = AppConfigKeys.MAX_READ_POOL_SIZE.ConfigValue().ToInt32(), AutoStart = true }; string[] readWriteHostsMixed = AppConfigKeys.REDIS_READ_WRITE_SERVERS.ConfigValue().Split(ASCII.SEMICOLON_CHAR); string[] readOnlyHostsMixed = AppConfigKeys.REDIS_READONLY_SERVERS.ConfigValue().Split(ASCII.SEMICOLON_CHAR); manager = new PooledRedisClientManager(readWriteHostsMixed, readOnlyHostsMixed, mixedConfig); break; default: break; } return(manager); }
public static IRedisCacheService RedisCacheServiceFactory(this RedisClientManagerType clientType) { var redisCacheService = default(IRedisCacheService); switch (clientType) { case RedisClientManagerType.NewsCache: redisCacheService = ObjectFactory.GetInstance <INewsRedisCacheService>(); break; case RedisClientManagerType.ThemeCache: redisCacheService = ObjectFactory.GetInstance <IThemeRedisCacheService>(); break; case RedisClientManagerType.MixedCache: redisCacheService = ObjectFactory.GetInstance <IRedisCacheService>(); break; default: redisCacheService = ObjectFactory.GetInstance <IRedisCacheService>(); break; } return(redisCacheService); }