Example #1
0
 /// <summary>
 /// Initialize a registered cache given by the ID.
 /// </summary>
 /// <param name="cacheId"></param>
 /// <param name="timeout"></param>
 /// <exception cref="ArgumentNullException">cacheId is a null reference (Nothing in Visual Basic).</exception>
 /// <returns>A reference to <see cref="Cache"/> object.</returns>
 public static Cache GetCacheInstance(string cacheId, TimeSpan timeout)
 {
     if (cacheId == null)
     {
         throw new ArgumentNullException("cacheId");
     }
     try
     {
         CacheConfig data = CacheConfigManager.GetCacheConfig(cacheId);
         return(GetCacheInstance(data, timeout));
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #2
0
        /// <summary>
        /// Load all the config sections from the configuration file.
        /// </summary>
        static private void LoadConfiguration(string cacheName)
        {
            try
            {
                CacheServerConfig[] configs = CacheConfigManager.GetConfiguredCaches();
                //Just need to call the static block - stupid logik i know
                Alachisoft.NCache.Util.MiscUtil.RegisterCompactTypes(null);
                if (configs != null)
                {
                    for (int i = 0; i < configs.Length; i++)
                    {
                        CacheServerConfig config = configs[i];
                        if (config != null && !String.IsNullOrEmpty(cacheName) && cacheName.ToLower().Equals(config.Name.ToLower()))
                        {
                            /// Until we completely move to using dom based configuration
                            ///we have to convert it to string props
                            string props = GetProps(config);
                            // all but the listed cache types are loaded in s_caches table.

                            string cacheId = config.Name.ToLower();

                            if (cacheInfo == null)
                            {
                                cacheInfo            = new CacheInfo();
                                cacheInfo.Cache      = new LeasedCache(props);
                                cacheInfo.CacheName  = cacheName;
                                cacheInfo.CacheProps = config;
                            }
                            else
                            {
                                cacheInfo.CacheProps = config;
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                string msg = String.Format("CacheServer failed to load configuration information, Error {0}",
                                           e.Message);
                AppUtil.LogEvent(msg, EventLogEntryType.Warning);
            }
        }
Example #3
0
 /// <summary>
 /// Load all the config sections from the configuration file.
 /// </summary>
 static private void LoadConfiguration(string cacheName)
 {
     try
     {
         CacheServerConfig[] configs = CacheConfigManager.GetConfiguredCaches();
         Alachisoft.NCache.Util.MiscUtil.RegisterCompactTypes();
         if (configs != null)
         {
             for (int i = 0; i < configs.Length; i++)
             {
                 CacheServerConfig config = configs[i];
                 if (config != null && !String.IsNullOrEmpty(cacheName) && cacheName.ToLower().Equals(config.Name.ToLower()))
                 {
                     string props   = GetProps(config);
                     string cacheId = config.Name.ToLower();
                     if (cacheInfo == null)
                     {
                         cacheInfo            = new CacheInfo();
                         cacheInfo.Cache      = new LeasedCache(props);
                         cacheInfo.CacheName  = cacheName;
                         cacheInfo.CacheProps = config;
                     }
                     else
                     {
                         cacheInfo.CacheProps = config;
                     }
                 }
             }
         }
     }
     catch (Exception e)
     {
         string msg = String.Format("CacheServer failed to load configuration information, Error {0}",
                                    e.Message);
         AppUtil.LogEvent(msg, EventLogEntryType.Warning);
     }
 }
Example #4
0
 /// <summary>
 /// static constructor
 /// </summary>
 static CacheConfigManager()
 {
     CacheConfigManager.ScanConfiguration();
 }