コード例 #1
0
        private object GetUrlRuleConfigCallBack(CacheItemArgs cacheItemArgs)
        {
            int PortalId = (int)cacheItemArgs.ParamList[0];
            UrlRuleConfiguration config = UrlRuleConfiguration.GenerateConfig(PortalId);

            string[]      keys   = UrlRuleConfiguration.GetCacheKeys(PortalId);
            List <string> keyLst = new List <string>();

            foreach (string key in keys)
            {
                if (DataCache.GetCache(key) != null)
                {
                    keyLst.Add(CachingProvider.GetCacheKey(key));
                }
            }
            keys = keyLst.ToArray();

            int CacheTimeout = 20 * Convert.ToInt32(DotNetNuke.Entities.Host.Host.PerformanceSetting);

            cacheItemArgs.CacheTimeOut    = CacheTimeout;
            cacheItemArgs.CacheDependency = new DNNCacheDependency(null, keys);

            #if DEBUG
            cacheItemArgs.CacheCallback = new CacheItemRemovedCallback(this.RemovedCallBack);
            #endif

            return(config);
        }
コード例 #2
0
 internal void ItemRemovedCallback(string key, object value, CacheItemRemovedReason removedReason)
 {
     try
     {
         if (Globals.Status == Globals.UpgradeStatus.None)
         {
             // track data removed from cache to synchonize UrlRule cache
             string[] CacheKeys = UrlRuleConfiguration.GetCacheKeys();
             if (CacheKeys != null)
             {
                 foreach (string CacheKey in CacheKeys)
                 {
                     if (key.Contains(CacheKey))
                     {
                         if (DotNetNuke.Entities.Portals.PortalSettings.Current != null)
                         {
                             int PortalId = DotNetNuke.Entities.Portals.PortalSettings.Current.PortalId;
                             Remove(GetCacheKey("UrlRuleConfig" + PortalId));
                             Logger.Trace("Clear cache " + key + " portal " + PortalId + " raison " + removedReason.ToString());
                         }
                         else
                         {
                             // Logger.Trace("Clear cache not executed " + key + " raison " + removedReason.ToString());
                         }
                     }
                 }
             }
             if (key.StartsWith("UrlRuleConfig"))
             {
                 Logger.Trace("cache " + key + "claired : " + removedReason.ToString());
             }
         }
     }
     catch (Exception exc)
     {
         //Swallow exception
         Logger.Error(exc);
     }
 }