Exemple #1
0
        private static void EnforceMaximumCacheSize()
        {
            // remove cache entries if the total cache size is above
            // MaximumCacheSize
            int sum  = 0;
            var keys = new List <string>();

            foreach (var pair in PreviousRender)
            {
                sum += pair.Value.Length;
                keys.Add(pair.Key);
            }
            Debug.WriteLine(string.Format("Memory footprint: {0} bytes in {1} items.", sum, keys.Count));
            if (sum <= MaximumCacheSize)
            {
                return;
            }
            int keyNr = keys.Count * sum / MaximumCacheSize;

            for (int c = 0; c < keyNr; c++)
            {
                PreviousRender.Remove(keys[c]);
                PreviousRenderTime.Remove(keys[c]);
            }
        }
Exemple #2
0
 /// <summary>
 /// clear the cached output of child update panels
 /// </summary>
 /// <param name="id"></param>
 private void ClearChildren(string id)
 {
     foreach (var pair in PanelTree)
     {
         if (pair.Value != id)
         {
             continue;
         }
         PreviousRender.Remove(Key + ":" + pair.Key);
         PreviousRenderTime.Remove(Key + ":" + pair.Key);
         ClearChildren(pair.Key);
     }
 }
Exemple #3
0
        private static void EnforceMaximumCacheTime()
        {
            var keys = new List <string>();

            foreach (var pair in PreviousRender)
            {
                DateTime dt;
                if (!PreviousRenderTime.TryGetValue(pair.Key, out dt))
                {
                    continue;
                }
                if ((DateTime.Now - dt).TotalMilliseconds > MaximumCacheTime)
                {
                    keys.Add(pair.Key);
                }
            }
            foreach (var key in keys)
            {
                PreviousRender.Remove(key);
                PreviousRenderTime.Remove(key);
            }
        }
Exemple #4
0
        private void InitFilter()
        {
            var session = HttpContext.Current.Session;

            if (session != null)
            {
                if (session.IsNewSession)
                {
                    session["InitializeSession"] = "Something";
                }
                _sessionID = session.SessionID;
            }
            ScriptManager sm = ScriptManager.GetCurrent(Page);

            if (sm != null)
            {
                if (!sm.IsInAsyncPostBack)
                {
                    if (_sessionID != null)
                    {
                        var keysToRemove = PreviousRender.Keys.Where(key => key.StartsWith(_sessionID + ":")).ToList();
                        foreach (string key in keysToRemove)
                        {
                            PreviousRender.Remove(key);
                            PreviousRenderTime.Remove(key);
                        }
                        EnsureKey();
                    }
                }
                else
                {
                    BuildPanelTree();
                }
                LoadApplyPatch();
            }
            ProcessCache();
        }