private void InitializeFactory()
        {
            EventLog.WriteEntry("Application", "InitiliazeFactory e girdi", EventLogEntryType.Information, 9888);

            try
            {
                CacheFactoryName    = _applicationSettingService.GetSetting("CoherenceCacheFactoryName");
                CoherenceConfigPath = _applicationSettingService.GetSetting("CoherenceConfigPath");
                //programmatically coherence cache configuration
                string configEnvironmentDirectory = _applicationSettingService.GetSetting("CoherenceConfigPath");

                var    relativePath        = AssemblyDirectory;
                string coherenceConfigPath = string.Format(relativePath + @"\" + configEnvironmentDirectory);

                CacheFactory.DefaultCacheConfigPath       = string.Format("file://{0}/{1}", coherenceConfigPath, "coherence-cache-config.xml");
                CacheFactory.DefaultOperationalConfigPath = string.Format("file://{0}/{1}", coherenceConfigPath, @"coherence.xml");
                CacheFactory.DefaultPofConfigPath         = string.Format("file://{0}/{1}", coherenceConfigPath, @"pof-config.xml");
                CacheFactory.Configure(CacheFactory.DefaultCacheConfigPath, CacheFactory.DefaultOperationalConfigPath);

                EventLog.WriteEntry("Application", "InitiliazeFactory "
                                    + CacheFactory.DefaultCacheConfigPath + " "
                                    + CacheFactory.DefaultOperationalConfigPath + " "
                                    + CacheFactory.DefaultPofConfigPath, EventLogEntryType.Information, 9888);

                EventLog.WriteEntry("Application", string.Format("CacheFactoryName {0} ", CacheFactoryName), EventLogEntryType.Information, 9888);

                //dynamic set cachefactoryname
                var cache = CacheFactory.GetCache(CacheFactoryName);
                cache.Release();
            }
            catch (Exception ex)
            {
                EventLog.WriteEntry("Application", string.Format("Error : {0}", ex), EventLogEntryType.Error, 9888);
                throw;
            }
        }
Пример #2
0
        private void InitializeFactory()
        {
            var configuration = new DataCacheFactoryConfiguration("default");
            var hostsSetting  = _applicationSettingService.GetSetting(DistributedCacheHostsKey);

            if (string.IsNullOrEmpty(hostsSetting))
            {
                throw new DataCacheException("AppFabric Cache Manager : The hosts are not defined!");
            }
            var hosts = hostsSetting.TrimEnd(';').Split(';').Where(s => !string.IsNullOrEmpty(s)).ToArray();

            if (!hosts.Any())
            {
                throw new DataCacheException("AppFabric Cache Manager : The hosts are not defined!");
            }
            var servers = hosts.Select(host => new DataCacheServerEndpoint(host.Trim(), 22233)).ToList();

            configuration.Servers = servers;

            _factory = new DataCacheFactory(configuration);
            var coreConfig = Engine.Resolve <CoreConfiguration>();

            _cache = _factory.GetCache(coreConfig.DistributedCacheName ?? AppFabricCacheName);
        }