public RedisService GetRedis(string name)
        {
            return(_services.GetOrAdd(name ?? string.Empty, key =>
            {
                var settings = ApplicationContext.Current.Configuration.GetOption <ConnectionSettingCollection>("/Externals/Redis/ConnectionSettings");

                if (settings != null)
                {
                    if (string.IsNullOrEmpty(key))
                    {
                        key = settings.Default ?? string.Empty;
                    }

                    if (settings.TryGet(key, out var setting))
                    {
                        return new RedisService(key, RedisServiceSettings.Parse(setting.Value));
                    }
                }

                return null;
            }));
        }
Beispiel #2
0
        public RedisService GetRedis(string name)
        {
            return(_services.GetOrAdd(name ?? string.Empty, key =>
            {
                var settings = ApplicationContext.Current.Configuration.GetOption <ConnectionSettingCollection>("/Externals/Redis/ConnectionSettings");

                if (settings != null)
                {
                    if (string.IsNullOrEmpty(key))
                    {
                        key = settings.Default ?? string.Empty;
                    }

                    if (settings.TryGet(key, out var setting))
                    {
                        return new RedisService(key, RedisServiceSettings.Parse(setting.Value));
                    }
                }

                throw new KeyNotFoundException($"The Redis service with the specified name '{key}' is undefined.");
            }));
        }