EPiWiki.se  - EPiServer notes shared with others
 

ListCache

[Edit]
ASP runtime cache explorer, to search and list keys in the cache.

<%@ Page Language="C#" AutoEventWireup="true" Inherits="System.Web.UI.Page" %>

<html>
<body>
    <form id="Form1" runat="server">
    <div>
        <asp:Button ID="Search" OnClick="OnClick_Search" runat="server" />
        <asp:TextBox ID="Query" runat="server" /><br />
        <asp:Literal ID="Result" runat="server" />

        <script runat="server">
            public void OnClick_Search(object sender, EventArgs e)
            {
                string searchString = Query.Text;

                System.Collections.Generic.List<string> keys =
                    new System.Collections.Generic.List<string>();
                foreach (System.Collections.DictionaryEntry item in
                         System.Web.HttpRuntime.Cache)
                {
                    if (!String.IsNullOrEmpty(searchString))
                    {
                        if (item.Value.GetType().FullName.IndexOf(searchString,
                                 StringComparison.InvariantCultureIgnoreCase) < 0
                            && item.Key.ToString().IndexOf(searchString,
                                 StringComparison.InvariantCultureIgnoreCase) < 0)
                        {
                            continue;
                        }
                    }

                    keys.Add(item.Key.ToString());
                }
                keys.Sort();
                StringBuilder result = new StringBuilder();
                foreach (string key in keys)
                {
                    object value = Cache[key];
                    result.AppendFormat("{1}&nbsp;&nbsp;&nbsp;({0})<br/>",
                        value != null ? value.GetType().ToString() : "null",
                        key);
                }

                Result.Text = result.ToString();
            }
        </script>

    </div>
    </form>
</body>
</html>

Version author:
Mattias Lövström

EPiServer version

All