Ejemplo n.º 1
0
        /// <summary>
        /// Recupera as configurações do DataCacheLoader.
        /// </summary>
        /// <returns></returns>
        private Colosoft.Caching.Configuration.Dom.CacheLoader GetDataCacheLoader()
        {
            var loader = new Colosoft.Caching.Configuration.Dom.CacheLoader();

            loader.Enabled       = true;
            loader.Retries       = 0;
            loader.RetryInterval = 0;
            loader.Provider      = new Colosoft.Caching.Configuration.Dom.ProviderAssembly {
                FullProviderName = "DataCacheLoader",
                AssemblyName     = "Colosoft.Data.Caching",
                ClassName        = "Colosoft.Data.Caching.DataCacheLoader"
            };
            return(loader);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Cria a configuração do cache.
        /// </summary>
        /// <returns></returns>
        private Colosoft.Caching.Configuration.Dom.CacheConfig CreateCacheConfig(Colosoft.Caching.Configuration.Dom.CacheLoader loader)
        {
            var config = new Colosoft.Caching.Configuration.Dom.CacheConfig();

            config.CacheType    = "local-cache";
            config.InProc       = false;
            config.ConfigID     = 0;
            config.Name         = "local-cache";
            config.CacheLoader  = loader;
            config.QueryIndices = GetQueryIndices();
            config.Storage      = new Colosoft.Caching.Configuration.Dom.Storage {
                Size = int.MaxValue,
                Type = "heap"
            };
            return(config);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Cria o cache com base no loader informado.
        /// </summary>
        /// <param name="loader"></param>
        private void CreateCache(Colosoft.Caching.Configuration.Dom.CacheLoader loader)
        {
            var config                = CreateCacheConfig(loader);
            var configProperties      = Colosoft.Caching.Configuration.Dom.ConfigConverter.ToHashtable(config);
            var cacheProperties       = (System.Collections.Hashtable)configProperties["cache"];
            var cacheLoaderProperties = (System.Collections.Hashtable)cacheProperties["cache-loader"];
            var loaderParameters      = new System.Collections.Hashtable();

            loaderParameters.Add("sourceContext", _sourceContext);
            loaderParameters.Add("manager", this);
            loaderParameters.Add("downloader", _dataEntryDownloader);
            loaderParameters.Add("repository", _dataEntriesRepository);
            loaderParameters.Add("logger", _logger);
            loaderParameters.Add("typeSchema", _typeSchema);
            loaderParameters.Add("cacheLoaderObserver", _cacheLoaderObserver);
            cacheLoaderProperties["parameters"] = loaderParameters;
            cacheProperties.Add("observer", this);
            _cache         = Colosoft.Caching.CacheFactory.CreateFromProperties(configProperties, config, true);
            _cache.Loaded += CacheLoaded;
        }