Ejemplo n.º 1
0
        /// <summary>
        /// Конструктор.
        /// </summary>
        /// <param name="environment">Окружение.</param>
        public CoreCachingConfig(CoreBaseEnvironment environment)
        {
            Environment = environment;

            FilePath = CreateFilePath();

            Settings = CoreCachingConfigSettings.Create(FilePath, Environment);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Конструктор.
 /// </summary>
 /// <param name="localStorageHelper">Помощник локального хранилища.</param>
 /// <param name="configSettings">Конфигурационные настройки.</param>
 /// <param name="resourceErrors">Ресурс ошибок.</param>
 public CoreCachingStorageGlobal(
     CoreCachingStorageLocalHelper localStorageHelper,
     ICoreCachingConfigSettings configSettings,
     CoreCachingResourceErrors resourceErrors
     )
 {
     Helper  = new CoreCachingStorageGlobalHelper(localStorageHelper, configSettings, resourceErrors);
     Service = new CoreCachingStorageGlobalService(Helper);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Конструктор.
        /// </summary>
        /// <param name="memoryCache">Кэш в памяти.</param>
        /// <param name="configSettings">Конфигурационные настройки.</param>
        /// <param name="resourceErrors">Ресурс ошибок.</param>
        public CoreCachingStorages(
            IMemoryCache memoryCache,
            ICoreCachingConfigSettings configSettings,
            CoreCachingResourceErrors resourceErrors
            )
        {
            Local = new CoreCachingStorageLocal(memoryCache, configSettings);

            if (configSettings.IsGlobalStorageEnabled)
            {
                Global = new CoreCachingStorageGlobal(Local.Helper, configSettings, resourceErrors);
            }
        }
        /// <summary>
        /// Конструктор помощника для глобального хранилища.
        /// </summary>
        /// <param name="helper">Помощник для локального хранилища.</param>
        /// <param name="configSettings">Конфигурационные настройки.</param>
        public CoreCachingStorageGlobalHelper(
            CoreCachingStorageLocalHelper helper,
            ICoreCachingConfigSettings configSettings,
            CoreCachingResourceErrors coreCachingResourceErrors
            )
        {
            Helper = helper;

            DbIndex = configSettings.DbIndex;

            ChannelPatternForRemoveData    = Helper.CacheKeyPrefix + ".remove.*";
            ChannelPatternForRemoveAllData = Helper.CacheKeyPrefix + ".flush*";

            var options = string.IsNullOrWhiteSpace(configSettings.Hosts)
                ?
                          ConfigurationOptions.Parse(string.Concat(configSettings.Host, ":", configSettings.Port))
                :
                          ConfigurationOptions.Parse(configSettings.Hosts);

            options.AllowAdmin         = true;
            options.Password           = configSettings.Password;
            options.AbortOnConnectFail = false;
            options.ConnectTimeout     = configSettings.ConnectTimeout;

            Connection = ConnectionMultiplexer.Connect(options);

            if (!Connection.IsConnected)
            {
                throw new CoreBaseException(
                          string.Format(
                              coreCachingResourceErrors.GetStringFormatUnableToConnectToRedis(),
                              configSettings.CoreBaseExtJsonSerialize(CoreBaseExtJson.OptionsForLogger)
                              )
                          );
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Конструктор помощника для локального хранилища.
 /// </summary>
 /// <param name="configSettings">Конфигурационные настройки.</param>
 public CoreCachingStorageLocalHelper(ICoreCachingConfigSettings configSettings)
 {
     CacheKeyPrefix  = configSettings.CacheKeyPrefix;
     ExpiryInSeconds = configSettings.CacheExpiryInSeconds;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Конструктор.
 /// </summary>
 /// <param name="memoryCache">Кэш в памяти.</param>
 /// <param name="configSettings">Конфигурационные настройки.</param>
 public CoreCachingStorageLocal(IMemoryCache memoryCache, ICoreCachingConfigSettings configSettings)
 {
     Helper  = new CoreCachingStorageLocalHelper(configSettings);
     Service = new CoreCachingStorageLocalService(Helper, memoryCache);
 }