Ejemplo n.º 1
0
        public void Remove(CacheConfig cacheConfig, object state = null)
        {
            CacheUtil.MegreConfig(cacheConfig);
            var key = CacheUtil.GetName(cacheConfig, state);

            RemoveCache(key);
        }
Ejemplo n.º 2
0
        public TReturnData GetAndAddData <TReturnData>(CacheConfig cacheConfig, Func <TReturnData> getData, object state = null)
        {
            CacheUtil.MegreConfig(cacheConfig);
            var key = CacheUtil.GetName(cacheConfig, state);

            return(GetAndAddData(key, cacheConfig.Duration.GetValueOrDefault(), getData, cacheConfig.DependencyKeys));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 添加缓存
        /// </summary>
        /// <param name="services"></param>
        /// <param name="cfg"></param>
        /// <returns></returns>
        public static IServiceCollection AddCache(this IServiceCollection services, IConfiguration cfg)
        {
            var config  = new CacheConfig();
            var section = cfg.GetSection("Cache");

            section?.Bind(config);

            services.AddSingleton(config);

            if (!config.IsEnabled) // 如果未启用缓存
            {
                return(services);
            }

            var assembly = AssemblyHelper.LoadByNameEndString($"Cache.{config.Provider}");

            Check.NotNull(assembly, $"缓存实现程序集({config.Provider})未找到");

            var handlerType = assembly.GetTypes().FirstOrDefault(m => typeof(ICacheHandler).IsAssignableFrom(m));

            if (handlerType != null)
            {
                services.AddSingleton(typeof(ICacheHandler), handlerType);
            }

            return(services);
        }
Ejemplo n.º 4
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMemoryCache();

            services.AddMvc();

            IConfigurationBuilder builder = new ConfigurationBuilder()
                                            .SetBasePath(this.HostingEnvironment.ContentRootPath)
                                            .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                                            .AddJsonFile($"appsettings.{this.HostingEnvironment.EnvironmentName}.json", optional: true)
                                            .AddEnvironmentVariables();

            var config = builder.Build();

            CacheConfig _cacheProvider = new CacheConfig();

            config.GetSection(nameof(CacheConfig)).Bind(_cacheProvider);

            if (_cacheProvider.RedisEnable)
            {
                //Use Redis
                services.AddSingleton(typeof(ICacheService), new RedisCacheService(new RedisCacheOptions
                {
                    Configuration = _cacheProvider.ConnectionString,
                    InstanceName  = _cacheProvider.InstanceName
                }));
            }
            else
            {
                //Use MemoryCache
                services.AddSingleton <IMemoryCache>(factory => new MemoryCache(new MemoryCacheOptions()));
                services.AddSingleton <ICacheService, MemoryCacheService>();
            }
        }
Ejemplo n.º 5
0
        private void _addObjetoSeguridad()
        {
            try
            {
                //  Login
                string strClaveSeg           = "#_OASis2006_#";
                CommonServices.Seguridad seg = new CommonServices.Seguridad();
                string fLogin    = seg.Encriptar(strClaveSeg, System.Configuration.ConfigurationManager.AppSettings["OAS_SitioWebLogin"]);
                string fPassword = seg.Encriptar(strClaveSeg, System.Configuration.ConfigurationManager.AppSettings["OAS_SitioWebPassword"]);
                this.LoginCache = new OAS_Seguridad.Cliente.OASisLogin(fLogin,
                                                                       fPassword,
                                                                       false);

                this.LoginCache.LoginUser();
                if (this.LoginCache.Authorized == false)
                {
                    CacheConfig.Remove("OASisLogin");
                    throw new System.Security.SecurityException("Acceso no autorizado", null as Exception);
                }
            }catch (Exception ex)
            {
                Errores err = new Errores();
                err.SetError(ex, "_addObjetoSeguridad");
            }
        }
        public static ICacheProvider BuildCacheProviderWithTraceLogging(this CacheConfig config)
        {
            var logger     = new Logger(config);
            var components = BuildComponents(config, logger);

            return(new CacheProvider(components.Cache, logger, config, components.DependencyManager, components.FeatureSupport));
        }
Ejemplo n.º 7
0
 public DaemonConfig(Version version, CommunicationConfig communication, CacheConfig cache, PathsConfig paths)
 {
     this.Version       = version;
     this.Communication = communication;
     this.Cache         = cache;
     this.Paths         = paths;
 }
Ejemplo n.º 8
0
        private ICache GetCache(CacheConfig config)
        {
            ICache cache = null;
            var    normalisedCacheToUse = !string.IsNullOrWhiteSpace(config.CacheToUse) ? config.CacheToUse.ToLowerInvariant() : string.Empty;

            switch (normalisedCacheToUse)
            {
            case CacheTypes.MemoryCache:
                cache = new MemoryCacheAdapter(_logger);
                break;

            case CacheTypes.WebCache:
                cache = new WebCacheAdapter(_logger);
                break;

            case CacheTypes.AppFabricCache:
                cache = new AppFabricCacheAdapter(_logger, config);
                break;

            case CacheTypes.memcached:
                cache = new memcachedAdapter(_logger, config);
                break;

            case CacheTypes.redis:
                cache = new RedisCacheAdapter(_logger, config);
                break;

            default:
                cache = new MemoryCacheAdapter(_logger);
                break;
            }
            return(cache);
        }
Ejemplo n.º 9
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string strReturnMsg = CheckInput();

            if (strReturnMsg != string.Empty)
            {
                MessageBox.Show(strReturnMsg);
                return;
            }
            //新增
            if (m_CacheConfig == null)
            {
                string strTableNameValueNew = cboEditTableName.SelectedValue.ToString().Trim();
                if (m_CacheConfigDAL.CalcCount("TableName='" + strTableNameValueNew + "'") > 0)
                {
                    MessageBox.Show(@"表名已经存在");
                    return;
                }

                CacheConfig model = EntityOperateManager.AddEntity <CacheConfig>(this.tabPage);
                model.CacheChekGuid  = Guid.NewGuid().ToString();
                model.CacheTableName = Guid.NewGuid().ToString();
                int intReturn = m_CacheConfigDAL.Add(model);
                if (intReturn > 0)
                {
                    MessageBox.Show(@"添加成功");
                    model.Id = intReturn;
                    m_lstCacheConfig.Add(model);
                    ListCacheConfig   = m_lstCacheConfig;
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show(@"添加失败");
                }
            }
            //修改
            else
            {
                string strTableNameValueEdit = cboEditTableName.SelectedValue.ToString().Trim();
                if (m_CacheConfigDAL.CalcCount(" Id !=" + m_CacheConfig.Id + "   and  TableName='" + strTableNameValueEdit + "'") > 0)
                {
                    MessageBox.Show(@"表名已经存在");
                    return;
                }

                m_CacheConfig = EntityOperateManager.EditEntity(this.tabPage, m_CacheConfig);
                bool blnReturn = m_CacheConfigDAL.Update(m_CacheConfig);
                if (blnReturn)
                {
                    MessageBox.Show(@"修改成功");
                    ListCacheConfig   = m_lstCacheConfig;
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show(@"修改失败");
                }
            }
        }
Ejemplo n.º 10
0
        private static void ExtractServerNodesFromConfig(CacheConfig config)
        {
            // Here we test to see if the old separator char is used.If not, we use the
            // preferred one, otherwise we revert to the obsolete one (for backwards compatibility)
            char separator = CacheConstants.ConfigDistributedServerSeparator;

            if (config.DistributedCacheServers.Contains(CacheConstants.ConfigDistributedServerSeparatorObsolete))
            {
                separator = CacheConstants.ConfigDistributedServerSeparatorObsolete;
            }
            var endPointList = config.DistributedCacheServers.Split(separator);

            if (endPointList.Length == 0)
            {
                return;
            }

            foreach (var endpoint in endPointList)
            {
                var endPointComponents = endpoint.Split(CacheConstants.ConfigDistributedServerPortSeparator);
                if (endPointComponents.Length < 2)
                {
                    continue;
                }

                int port;
                if (int.TryParse(endPointComponents[1], out port))
                {
                    var cacheEndpoint = new ServerNode(endPointComponents[0], port);
                    config.ServerNodes.Add(cacheEndpoint);
                }
            }
        }
Ejemplo n.º 11
0
        /// <summary>编辑
        ///
        /// </summary>
        private void DoEdit()
        {
            string strMsg = CheckSelect("修改");

            if (strMsg != string.Empty)
            {
                MessageBox.Show(strMsg);
                return;
            }
            DataGridViewRow drRowEdit = grdData.SelectedRows[0];
            CacheConfig     model     = drRowEdit.Tag as CacheConfig;

            if (model == null)
            {
                int intKeyID = int.Parse(drRowEdit.Cells[gridmrzId.Name].Value.ToString());
                model = m_CacheConfigDAL.GetModel(intKeyID);
            }
            if (model != null)
            {
                FrmCacheConfigSimpleDialog frmDialog = new FrmCacheConfigSimpleDialog(model, m_lstCacheConfig);
                if (frmDialog.ShowDialog() == DialogResult.OK)
                {
                    m_lstCacheConfig   = frmDialog.ListCacheConfig;
                    grdData.DataSource = m_lstCacheConfig;
                    grdData.Refresh();
                }
            }
        }
Ejemplo n.º 12
0
        public bool updateConfigCache(CacheConfig info)
        {
            bool result = true;

            DocsPaUtils.Query q = DocsPaUtils.InitQuery.getInstance().getQuery("U_CONFIG_CACHE");
            q.setParam("idAmministrazione", "'" + info.idAmministrazione + "'");
            if (info.caching)
            {
                q.setParam("caching", "1");
            }
            else
            {
                q.setParam("caching", "0");
            }
            q.setParam("massima_dimensione_caching", info.massima_dimensione_caching.ToString());
            q.setParam("massima_dimensione_file", info.massima_dimensione_file.ToString());
            q.setParam("doc_root_server", "'" + info.doc_root_server + "'");
            q.setParam("ora_inizio_cache", "'" + info.ora_inizio_cache + "'");
            q.setParam("ora_fine_cache", "'" + info.ora_fine_cache + "'");
            q.setParam("urlwscaching", "'" + info.urlwscaching + "'");
            q.setParam("urlwscachinglocale", "'" + info.url_ws_caching_locale + "'");
            q.setParam("doc_root_server_locale", "'" + info.doc_root_server_locale + "'");
            string sql = q.getSQL();

            logger.Debug("updateConfigCache - query: " + sql);
            if (!this.ExecuteNonQuery(sql))
            {
                result = false;
                throw new Exception();
            }
            return(result);
        }
Ejemplo n.º 13
0
        private ICacheDependencyManager GetCacheDependencyManager(CacheConfig config, ICache cache)
        {
            ICacheDependencyManager dependencyMgr = null;
            var normalisedDependencyManagerConfig = !string.IsNullOrWhiteSpace(config.DependencyManagerToUse) ? config.DependencyManagerToUse.ToLowerInvariant() : string.Empty;

            switch (normalisedDependencyManagerConfig)
            {
            case CacheDependencyManagerTypes.Default:
                dependencyMgr = GetRedisCacheDependencyManagerIfApplicable(config, cache);
                break;

            case CacheDependencyManagerTypes.Redis:
                dependencyMgr = GetRedisCacheDependencyManagerIfApplicable(config, cache);
                break;

            case CacheDependencyManagerTypes.Generic:
                dependencyMgr = new GenericDependencyManager(cache, _logger, config);
                break;

            case CacheDependencyManagerTypes.Unspecified:
                // try and determine what one to use based on the cache type
                dependencyMgr = GetRedisCacheDependencyManagerIfApplicable(config, cache);
                break;

            default:
                dependencyMgr = new GenericDependencyManager(cache, _logger, config);
                break;
            }
            return(dependencyMgr);
        }
Ejemplo n.º 14
0
        public SignalCharting(ISignalChart chartControl, TickerType tickerType, BarItemType barType, object dataStreamSource)
        {
            this.dataStreamSource    = dataStreamSource;
            this.tickerType          = tickerType;
            this.barType             = barType;
            this.chartControl        = chartControl;
            this.registeredAnalytics = new List <AnalyticsItem>();

            SharedCacheFactory.Instance.CacheWriter = new FileCacheWriter("cache");
            SharedCacheFactory.Instance.CacheReader = new FileCacheReader("cache");

            if (dataStreamSource is string)
            {
                FileInfo    file        = new FileInfo(dataStreamSource.ToString());
                long        fileHash    = file.Attributes.GetHashCode() ^ file.CreationTime.Ticks ^ file.LastWriteTime.Ticks ^ file.Length;
                CacheConfig cacheConfig = new CacheConfig("cache");
                cacheConfig.Initialize();
                cacheConfig.Open(CachingModeOption.Reading);
                CacheRow row = cacheConfig.Read(fileHash);
                cacheConfig.Close();

                if (row == null)
                {
                    cacheConfig.Open(CachingModeOption.Writing);
                    cacheId = Guid.NewGuid();
                    cacheConfig.Append(fileHash, cacheId, SessionModeOption.Backtesting);
                    cacheConfig.Close();
                }
                else
                {
                    cacheId = new Guid((byte[])row["SessionId"]);
                }
            }
        }
Ejemplo n.º 15
0
        static void Main(string[] args)
        {
            CacheConfig config = new CacheConfig();

            //config.LoadConfig("");
            config.CacheTime  = 1800;
            config.Policy     = CachePolicy.FIFO;
            config.PersPolicy = PersistencePolicy.Expire;
            ICache <int, int> cache = CacheFactory <int, int> .Create(config);

            cache.CacheRemoveListener += Cache_CacheRemoveListener;

            for (int i = 0; i < 10; i++)
            {
                Task.Factory.StartNew(() =>
                {
                    int num = i * 10;
                    for (int j = num; j < num + 10000; j++)
                    {
                        cache.Add(j, j);
                    }
                });
            }
            Thread.Sleep(10000);
            int reslut = 0;

            if (cache.TryGetCache(10020, out reslut))
            {
                Console.WriteLine(reslut);
            }
            Console.Read();
        }
Ejemplo n.º 16
0
        public AppFabricCacheAdapter(ILogging logger, CacheConfig config = null)
        {
            _logger  = logger;
            _factory = new AppFabricCacheFactory(_logger, config);

            _cache = _factory.ConstructCache();
        }
Ejemplo n.º 17
0
        static CacheService()
        {
            if (_G.EnabledCache == false && _G.RefurbishCache == false)
                return;

            DefaultCache = new CacheConfig();

            DefaultCache.Enabled = true;
            DefaultCache.Address = "ch5Live";
            DefaultCache.Port = "11211";
            DefaultCache.MinPoolSize = 10;
            DefaultCache.MaxPoolSize = 100;
            DefaultCache.ConnectionTimeout = 1000;

            COMMONT = Get("Live", "Commont2", 60 * 30, false);

            CHECK_INFO = Get("Live", "Check_INFO2", 60 * 30, false);

            UserExt = Get("Live", "UserExt2", 60 * 30, false);

            Message = Get("Live", "Message2", 60 * 10, false);

            Topic = Get("Live", "Topic2", 60 * 10, false);

            Mall = Get("Mall", "m", 60 * 5, false);

            Snapup = Get("Snapup", "s", 60 * 5, false);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Application Start
        /// </summary>
        protected void Application_Start()
        {
            log4net.Config.XmlConfigurator.Configure();
            LogService.Instance.SetApplicationVariables(DomainApplicationService.Instance.MachineName, DomainApplicationService.Instance.ApplicationCode);

            LogService.Instance.Log.InfoFormat("Global.asax Application_Start() Called.");

            DomainApplicationService.Instance.IOCContainer = new ClientBootstrapper().Run();

            GlobalConfiguration.Configure(WebApiConfig.Register);
            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            EntityConfig.Register();
            CacheConfig.PreloadItems();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            ModelBinderConfig.Register();

            //
            //If you want to ignore the certificate check when requesting an https resource, uncomment the following code.
            //This is useful if your app connects uses https/ssl resources which dont have a cert issued by a valid
            //signing authority.
            //This should probably never be uncommented in a production app though. Its here for reference in case its needed.
            //
            //ServicePointManager.ServerCertificateValidationCallback = delegate
            //{
            //    return true;
            //};
        }
Ejemplo n.º 19
0
        static CacheConfig AutoConfigMaster()
        {
            string localHost = "localhost";

            CacheConfig config = new CacheConfig();

            //
            //  Master
            //
            config.MasterHostName   = localHost;
            config.MasterPortNumber = 7709;
            config.Ring             = new CacheRing();
            //
            //  Listener
            //
            config.ListenerHostName   = localHost;
            config.ListenerIP         = "127.0.0.1";
            config.ListenerPortNumber = 7709;
            config.IsMaster           = true;
            //
            //  Trace
            //
            config.IsTraceEnabled = false;
            config.TraceFilePath  = string.Format("D:\\CacheSupport\\Logs\\Master_{0}.txt", 7710);

            return(config);
        }
        public static CacheFactoryComponentResult BuildComponents(this CacheConfig config, ILogging logger)
        {
            var resolver = new CacheAdapterResolver(logger);
            var factory  = resolver.GetCacheConstructionFactoryUsingConfig(config);

            return(factory.CreateCacheComponents());
        }
Ejemplo n.º 21
0
        public static ICacheProvider GetCacheProvider()
        {
            var provider = CacheConfig.Create()
                           .BuildCacheProviderWithTraceLogging();

            return(provider);
        }
Ejemplo n.º 22
0
        public CacheConfig getConfigurazioneCache(string idAmministrazione)
        {
            CacheConfig info = null;

            DocsPaUtils.Query queryDef = DocsPaUtils.InitQuery.getInstance().getQuery("S_CONFIG_CACHE");
            queryDef.setParam("idAmministrazione", "'" + idAmministrazione + "'");
            logger.Debug("getConfigurazioneCache - query :" + queryDef.getSQL());
            string commandText = queryDef.getSQL();

            using (DocsPaDB.DBProvider dbProvider = new DocsPaDB.DBProvider())
            {
                using (System.Data.IDataReader reader = dbProvider.ExecuteReader(commandText))
                {
                    if (reader != null)
                    {
                        while (reader.Read())
                        {
                            info                            = new CacheConfig();
                            info.caching                    = reader.GetInt32(reader.GetOrdinal("CACHING")) == 1 ? true : false;
                            info.doc_root_server            = reader.GetString(reader.GetOrdinal("DOC_ROOT_SERVER"));
                            info.massima_dimensione_caching = reader.GetDouble(reader.GetOrdinal("MASSIMA_DIMENSIONE_CACHING"));
                            info.massima_dimensione_file    = reader.GetDouble(reader.GetOrdinal("MASSIMA_DIMENSIONE_FILE"));
                            info.idAmministrazione          = reader.GetString(reader.GetOrdinal("idAmministrazione"));
                            info.ora_fine_cache             = reader.GetString(reader.GetOrdinal("ORA_FINE_CACHE"));
                            info.ora_inizio_cache           = reader.GetString(reader.GetOrdinal("ORA_INIZIO_CACHE"));
                            info.urlwscaching               = reader.GetString(reader.GetOrdinal("urlwscaching"));
                            info.url_ws_caching_locale      = reader.GetString(reader.GetOrdinal("url_ws_caching_locale"));
                            info.doc_root_server_locale     = reader.GetString(reader.GetOrdinal("doc_root_server_locale"));
                        }
                    }
                }
            }
            return(info);
        }
Ejemplo n.º 23
0
 /// <summary>
 /// Initialise the container with core dependencies. The cache/cache provider should be set to be
 /// singletons if adapting to use with a Dependency Injection mechanism
 /// </summary>
 /// <remarks>Note: In a .Net 4 web app, this method could be invoked using the new PreApplicationStartMethod attribute
 /// as in: <code>[assembly: PreApplicationStartMethod(typeof(MyStaticClass), "PreStartInitialise")]</code>
 /// Also note this section should be replaced with the DependencyInjection container of choice. This
 /// code simply acts as a cheap and simple utility mechanism for this without requiring a dependency on a
 /// container that you dont like/use. You can opt to replace the ICacheAdapterResolver with
 /// your resolver of choice as well to utilise your own dependency resolution mechanism.
 /// </remarks>
 public static void PreStartInitialise(ILogging logger = null, CacheConfig config = null, ICacheAdapterResolver resolver = null)
 {
     if (!_isInitialised)
     {
         lock (_lockRef)
         {
             if (!_isInitialised)
             {
                 try
                 {
                     _cacheProvider = CacheBinder.ResolveCacheFromConfig(config, logger, resolver);
                     CacheBinder.Logger.WriteInfoMessage(string.Format("Initialised cache of type: {0}", CacheBinder.Configuration.CacheToUse));
                     _cache         = _cacheProvider.InnerCache;
                     _isInitialised = true;
                 }
                 catch (Exception ex)
                 {
                     var outerEx = new ApplicationException(string.Format("Problem initialising cache of type: {0}", CacheBinder.Configuration.CacheToUse), ex);
                     CacheBinder.Logger.WriteException(outerEx);
                     throw outerEx;
                 }
             }
         }
     }
 }
Ejemplo n.º 24
0
        public void Custom_config_build_key_then_valid()
        {
            var config = new CacheConfig(pattern: "{key}:{region}");
            var key    = config.BuildCacheKey("r", "k");

            Assert.AreEqual(key, "k:r");
        }
 internal void MapSettingsFromConfigToAppFabricSettings(CacheConfig config, DataCacheFactoryConfiguration factoryConfig)
 {
     SetSecuritySettings(config, factoryConfig);
     SetMaxConnectionsToServer(config, factoryConfig);
     SetChannelOpenTimeout(config, factoryConfig);
     SetLocalCacheConfiguration(config, factoryConfig);
 }
Ejemplo n.º 26
0
 public AppConfig()
 {
     Azure    = new AzureConfig();
     Database = new DatabaseConfig();
     Logging  = new LoggingConfig();
     Cache    = new CacheConfig();
 }
Ejemplo n.º 27
0
        public override string GetKey(CacheConfig config, object state)
        {
            IContext context = (IContext)state;
            var      prefix  = GetRealText(config.KeyPrefix, context);
            var      key     = GetRealText(config.Key, context);

            return(BuildKey(prefix, key));
        }
Ejemplo n.º 28
0
 public Logger(CacheConfig config = null)
 {
     if (config == null)
     {
         config = new CacheConfig();
     }
     _config = config;
 }
Ejemplo n.º 29
0
 public UserConfig(string activeRelease, DatabasesConfig databases, EnvironmentVariablesConfig environmentVariables, CacheConfig cache, BeepsConfig beeps)
 {
     mActiveRelease = activeRelease;
     mDatabases = databases;
     mEnvironmentVariables = environmentVariables;
     mCache = cache;
     mBeeps = beeps;
 }
Ejemplo n.º 30
0
 /// <summary>
 /// Construct the ICacheProvider implementation using the configuration provided, the
 /// logging implementation provided, and the cache adapter resolver provided. If
 /// any of these items are passed as null, the existing values/settings are used. If there
 /// are no existing settings, then the default implementation is used.
 /// </summary>
 /// <param name="config">Configuration to use when creating the cache engine. if NULL
 /// is passed in, then the configuration is created based on values in the configuration file.</param>
 /// <param name="logger">The logging implementation to use. If NULL is provided, then the
 /// generic logging implementation is used.</param>
 /// <param name="resolver">The CacheAdapter resolver to use. If NULL is provided, the
 /// default resolver is used. You would typically provided your own resolver if you
 /// wanted to use different dependency resolution engines such as Ninject or Autofac which
 /// provide much richer lifetime support.</param>
 /// <returns></returns>
 public static ICacheProvider ResolveCacheFromConfig(CacheConfig config, ILogging logger = null, ICacheAdapterResolver resolver = null)
 {
     _config   = config;
     _logger   = logger;
     _resolver = resolver;
     EnsureObjectPropertiesAreValidObjects();
     return(_resolver.ResolveCacheFromConfig(_config));
 }
 public static CacheConfig UsingDistributedServerNodes(this CacheConfig config, IEnumerable <string> nodeAddresses)
 {
     nodeAddresses.ToList().ForEach(n =>
     {
         AddServerNodeIfNotPresent(config, n);
     });
     return(config);
 }
Ejemplo n.º 32
0
 private void dataNavigator_PositionChanged(object sender, EventArgs e)
 {
     if (dataNavigator.ListInfo == null)
     {
         return;
     }
     m_CacheConfig = m_lstCacheConfig[this.dataNavigator.CurrentIndex];
     DisplayData(m_CacheConfig);
 }
 public MemoryCache[] CreateCache(CacheConfig[] configuration)
 {
     var result = new List<MemoryCache>(configuration.Length);
     foreach (var config in configuration)
     {
         result.Add(new MemoryCache(config.Region, config.Properties));
     }
     return result.ToArray();
 }
Ejemplo n.º 34
0
        public Dictionary<string, CacheConfig> Read()
        {
            Dictionary<String, CacheConfig> dic = new Dictionary<string, CacheConfig>();
            try
            {
                string path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "CacheConfig.xml");
                if (!System.IO.File.Exists(path))
                    path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"bin\CacheConfig.xml");

                if (!System.IO.File.Exists(path))
                    return dic;

                XElement tables = XElement.Load(path);
                var list = tables.Descendants("Table");
                foreach (var item in list)
                {
                    var name = GetName(item);
                    if (name != "")
                    {
                        var cacheConfig = new CacheConfig();
                        cacheConfig.Name = name;
                        cacheConfig.CacheMode = GetCacheMode(item);

                        if (cacheConfig.CacheMode == CacheMode.OnFind)
                            cacheConfig.Size = GetSize(item);
                        else
                            cacheConfig.Size = 0;

                        cacheConfig.SortBy = GetExpression(item);
                        cacheConfig.Predicate = GetPredicate(item);

                        dic.Add(name, cacheConfig);
                    }
                }
            }
            catch
            {
                dic = new Dictionary<string, CacheConfig>();
            }

            return dic;
        }
 public GarbageCollectContext(CacheConfig cacheConfig, bool dryRun, ILog log)
 {
     mCacheConfig = cacheConfig;
     mDryRun = dryRun;
     mLog = log;
 }