コード例 #1
0
ファイル: ConfigController.cs プロジェクト: vamone/Routing
        private void ConfigFileChangesCacheCallback(string key, object value, System.Web.Caching.CacheItemRemovedReason reason)
        {
            DetectConfigFileChanges();

            // It only considers that the file was modified when the reason is 'DependencyChanged'. This is because the cache item could be removed for other reasons, among them when the AppDomain is restarted (web.config modified, ...)
            if (reason == CacheItemRemovedReason.DependencyChanged)
            {
                // Delete the persistent cache's file and clear the persistent cache stored in memory
                new PersistentCacheController().ResetPersistentCache();

                LogHelper.Warn <ConfigController>("Routing config file change detected.");
            }
        }
コード例 #2
0
ファイル: Globals.cs プロジェクト: zhangbo27/bbsmax
        /// <summary>
        /// 一旦bbsmax.config发生了变动会立即触发本静态方法
        /// </summary>
        /// <param name="key"></param>
        /// <param name="cacheItem"></param>
        /// <param name="reason"></param>
        private static void OnAppConfigRemove(string key, object cacheItem, System.Web.Caching.CacheItemRemovedReason reason)
        {
            AppConfig newConfig = null;

            try
            {
                newConfig = ReadAppConfig();
            }
            catch
            {
                //读取配置文件发生错误
                s_AppConfig = null;
                HttpRuntime.UnloadAppDomain();
                throw;
            }

            //一旦连接字符串和提供程序发生了变化,马上重启应用程序
            if (newConfig.ConnectionString != s_AppConfig.ConnectionString
                ||
                newConfig.DataProviderName != s_AppConfig.DataProviderName
                ||
                newConfig.InstallDirectory != s_AppConfig.InstallDirectory
                ||
                newConfig.PassportClient != s_AppConfig.PassportClient
                )
            {
                s_AppConfig = newConfig;
                HttpRuntime.UnloadAppDomain();
            }
            else
            {
                string configFilePath = GetConfigFilePath();
                //创建一个缓存,目的是监视bbsmax.config文件的改动
                HttpRuntime.Cache.Add("bbsmax.config", true, new System.Web.Caching.CacheDependency(configFilePath), Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, OnAppConfigRemove);

                //如果压缩设置发生了变化
                if (newConfig.StaticCompress != s_AppConfig.StaticCompress
                    ||
                    newConfig.DynamicCompress != s_AppConfig.DynamicCompress
                    ||
                    newConfig.Licence != s_AppConfig.Licence
                    ||
                    IsOwnerUsernamesSame(newConfig.OwnerUsernames, s_AppConfig.OwnerUsernames)

                    )
                {
                    s_AppConfig = newConfig;
                }
            }
        }
コード例 #3
0
        private void ItemRemoved(string fullKey, object item, System.Web.Caching.CacheItemRemovedReason reason)
        {
            if (string.IsNullOrWhiteSpace(fullKey))
            {
                return;
            }

            // ignore manually removed items, stats will be updated already
            if (reason == System.Web.Caching.CacheItemRemovedReason.Removed)
            {
                return;
            }

            bool   isToken;
            bool   hasRegion;
            string key;
            string region;

            ParseKeyParts(_instanceKeyLength, fullKey, out isToken, out hasRegion, out region, out key);

            if (!isToken)
            {
                if (hasRegion)
                {
                    Stats.OnRemove(region);
                }
                else
                {
                    Stats.OnRemove();
                }

                var    cacheItem     = item as CacheItem <TCacheValue>;
                object originalValue = null;
                if (item != null)
                {
                    originalValue = cacheItem.Value;
                }

                // trigger cachemanager's remove on evicted and expired items
                if (reason == System.Web.Caching.CacheItemRemovedReason.Underused)
                {
                    TriggerCacheSpecificRemove(key, region, Core.Internal.CacheItemRemovedReason.Evicted, originalValue);
                }
                else if (reason == System.Web.Caching.CacheItemRemovedReason.Expired)
                {
                    TriggerCacheSpecificRemove(key, region, Core.Internal.CacheItemRemovedReason.Expired, originalValue);
                }
            }
        }
コード例 #4
0
ファイル: Caching.cs プロジェクト: thinhtp/liteweb.info
        public static void TimeoutUser(string key, object v, System.Web.Caching.CacheItemRemovedReason r)
        {
            //   return;
            if (r == CacheItemRemovedReason.Removed ||
                r == CacheItemRemovedReason.DependencyChanged ||
                r == CacheItemRemovedReason.Expired)
            {
                string userId = v.ToString();

                WebContext.CreateHttpContext();

                try
                {
                    MembersManager.UpdateOnlineStatus(Int32.Parse(userId), false);
                }
                catch (Exception Ex)
                {
                    throw (Ex);
                }
            }
        }
コード例 #5
0
ファイル: CategoryCaching.cs プロジェクト: mkurtt/.NET-C-MVC-
        private static void OnRemoveCallBack(string key, object data, ch.CacheItemRemovedReason reason)
        {
            switch (reason)
            {
            case System.Web.Caching.CacheItemRemovedReason.DependencyChanged:
                //Log
                break;

            case System.Web.Caching.CacheItemRemovedReason.Expired:

                //Renew
                break;

            case System.Web.Caching.CacheItemRemovedReason.Removed:
                //Log
                break;

            case System.Web.Caching.CacheItemRemovedReason.Underused:

                break;
            }
        }
コード例 #6
0
 //***************************************************************************************************************************************
 public static void OnRemove(string key, object cacheItem, System.Web.Caching.CacheItemRemovedReason reason)
 {
     //When the cache expires then reload it from the API call.
     ModuleCatalogueCache.Instance.LoadModules();
 }
コード例 #7
0
 public static void ReportRemovedAGSTokenCallback(String key, object value,
                                                  System.Web.Caching.CacheItemRemovedReason removedReason)
 {
     GenerateAGSToken();
 }
コード例 #8
0
 public void RemovedCallback(String k, Object v, System.Web.Caching.CacheItemRemovedReason r)
 {
     //do stuff when the item is removed
 }