Beispiel #1
0
        private void InitializeCache()
        {
            lock (s_dataLock)
            {
                try
                {
                    if (_cache == null)
                    {
                        LegacyProvider.s_onAppDomainUnload = new EventHandler(OnAppDomainUnload);
                        System.Threading.Thread.GetDomain().DomainUnload += LegacyProvider.s_onAppDomainUnload;

                        if (_logs || _detailedLogs)
                        {
                            if (_ncacheLog == null)
                            {
                                _ncacheLog = new NCacheLogger();
                                _ncacheLog.Initialize(LoggerNames.SessionStoreProvider, _cacheId);

                                if (_detailedLogs)
                                {
                                    NCacheLog.SetLevel("all");
                                }
                                else
                                {
                                    if (_logs)
                                    {
                                        NCacheLog.SetLevel("info");
                                    }
                                }
                            }
                        }
                        if (_isLocationAffinityEnabled)
                        {
                            _cache = new RegionalCache(_ncacheLog, NCacheSessionStateConfigReader.LoadSessionLocationSettings());
                        }
                        else
                        {
                            _cache = new SingleRegionCache(_operationRetry, _operationRetryInterval);
                        }

                        _cache.InitializeCache(_cacheId);
                        _cache.ExceptionsEnabled = true;
                        s_cacheNeedInit          = false;
                        if (_logs)
                        {
                            NCacheLog.Info("NSessionStoreProvider initialized");
                        }
                        Thread.Sleep(_inprocDelay);
                    }
                }
                catch (Exception exc)
                {
                    _cache = null; // so that next time cache can be initialized. Check the above condition if(_cache == null)
                    RaiseException(exc);
                }
            }
        }
Beispiel #2
0
        private void InitializeCache()
        {
            lock (s_dataLock)
            {
                try
                {
                    //if (StaticLogs.IsWriterNull && _logs) StaticLogs.Initialize(_cacheId, "SessionStoreProvider");

                    if (_cache == null)
                    {
                        if (_logs || _detailedLogs)
                        {
                            if (_ncacheLog == null)
                            {
                                string logFileNmae = _cacheId;

                                _ncacheLog = new NCacheLogger();
                                _ncacheLog.Initialize(LoggerNames.SessionStoreProvider, logFileNmae);

                                if (_detailedLogs)
                                {
                                    NCacheLog.SetLevel("all");
                                }
                                else
                                {
                                    if (_logs)
                                    {
                                        NCacheLog.SetLevel("info");
                                    }
                                }
                            }
                        }

                        _cache = new SingleRegionCache(_operationRetry, _operationRetryInterval);

                        _cache.InitializeCache(_cacheId);
                        s_cacheNeedInit = false;
                        OnCacheInitialize();
                        if (_logs)
                        {
                            LogInfo("NSessionStoreProvider initialized", null);
                        }
                        Thread.Sleep(_inprocDelay);
                    }
                }
                catch (Exception exc)
                {
                    _cache = null; //taimoor: so that next time cache can be initialized. Check the above condition if(_cache == null)
                    LogError(exc, null);
                }
            }
        }
        private void InitializeCache()
        {
            lock (s_dataLock)
            {
                try
                {
                    if (_cache == null)
                    {
                        NSessionStoreProvider.s_onAppDomainUnload = new EventHandler(OnAppDomainUnload);
                        System.Threading.Thread.GetDomain().DomainUnload += NSessionStoreProvider.s_onAppDomainUnload;

                        if (_logs || _detailedLogs)
                        {
                            if (_ncacheLog == null)
                            {
                                _ncacheLog = new NCacheLogger();
                                _ncacheLog.Initialize(LoggerNames.SessionStoreProvider, _cacheId);

                                if (_detailedLogs)
                                {
                                    NCacheLog.SetLevel("all");
                                }
                                else
                                {
                                    if (_logs)
                                        NCacheLog.SetLevel("info");
                                }
                            }
                        }

                        _cache = new SingleRegionCache(_operationRetry, _operationRetryInterval);
                        _cache.InitializeCache(_cacheId);
                        _cache.ExceptionsEnabled = true;
                        s_cacheNeedInit = false;
                        if(_logs) NCacheLog.Info("NSessionStoreProvider initialized");
                        Thread.Sleep(_inprocDelay);
                    }
                }
                catch (Exception exc)
                {
                    _cache = null; // so that next time cache can be initialized. Check the above condition if(_cache == null)
                    RaiseException(exc);
                }
            }
        }
        private void InitializeCache()
        {
            lock (s_dataLock)
            {
                try
                {
                    if (_cache == null)
                    {
                        if (_logs || _detailedLogs)
                        {
                            if (_ncacheLog == null)
                            {
                                string logFileNmae = _cacheId;

                                if (_isLocationAffinityEnabled && _regionalCacheSessionStateSettings.PrimaryCache != null)
                                {
                                    foreach (string prefix in _regionalCacheSessionStateSettings.PrimaryCache.Keys)
                                    {
                                        logFileNmae = _regionalCacheSessionStateSettings.PrimaryCache[prefix] as string;
                                        break;
                                    }
                                }

                                _ncacheLog = new NCacheLogger();
                                _ncacheLog.Initialize(LoggerNames.SessionStoreProvider, logFileNmae);

                                if (_detailedLogs)
                                {
                                    NCacheLog.SetLevel("all");
                                }
                                else
                                {
                                    if (_logs)
                                    {
                                        NCacheLog.SetLevel("info");
                                    }
                                }
                            }
                        }
                        if (_isLocationAffinityEnabled)
                        {
                            string sid    = string.Empty;
                            string pcache = string.Empty;

                            if (_regionalCacheSessionStateSettings.PrimaryCache != null)
                            {
                                foreach (string prefix in _regionalCacheSessionStateSettings.PrimaryCache.Keys)
                                {
                                    sid    = prefix;
                                    pcache = _regionalCacheSessionStateSettings.PrimaryCache[prefix] as string;
                                    break;
                                }
                            }

                            if (_logs)
                            {
                                LogInfo("NsessionStoreProvider.Initialize() -> primary cache and sid : " + pcache + " : " + sid, null);
                            }
                            _cache = new RegionalCache(_ncacheLog, _regionalCacheSessionStateSettings);
                        }
                        else
                        {
                            _cache = new SingleRegionCache(_operationRetry, _operationRetryInterval);
                        }

                        _cache.InitializeCache(_cacheId);
                        _cache.ExceptionsEnabled = true;
                        s_cacheNeedInit          = false;
                        OnCacheInitialize();
                        if (_logs)
                        {
                            LogInfo("NSessionStoreProvider initialized", null);
                        }
                        Thread.Sleep(_inprocDelay);
                    }
                }
                catch (Exception exc)
                {
                    _cache = null; // so that next time cache can be initialized. Check the above condition if(_cache == null)
                    LogError(exc, null);
                }
            }
        }