Cache Manager

Cache Manager

Controls featured in this example:

  • Sitecore Web Control

Classes featured in this example:

  • Sitecore.Caching.AccessResultCache
  • Sitecore.Caching.CacheManager
  • Sitecore.Caching.IsUserInRole.IsUserInRoleCache
  • Sitecore.Caching.UserProfile.UserProfileCache
  • Sitecore.Context
  • Sitecore.Data.Items.Item

Cache Manager C# Web Control Code

output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold; width:100%; clear:both");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Div);
output.Write("C# Web Control Real-time Output");
output.RenderEndTag();

Sitecore.Data.Items.Item item = Sitecore.Context.Item;
if (item == null) return;

output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-size:x-small; width:100%; clear:both");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Div);
output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.P);
//using : for colon and   for space
output.Write("{0}&#58;&#160;{1}", "Item", "<b>" + item.DisplayName + "</b>");
output.RenderEndTag(); //

Sitecore.Caching.AccessResultCache accessResultCache = Sitecore.Caching.CacheManager.GetAccessResultCache();
Sitecore.Caching.IsUserInRole.IsUserInRoleCache isInRoleCache = Sitecore.Caching.CacheManager.GetIsInRoleCache();
Sitecore.Caching.UserProfile.UserProfileCache userProfileCache = Sitecore.Caching.CacheManager.GetUserProfileCache();

output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.P);
output.Write("{0}", "Access Result Cache");
output.RenderEndTag(); //P
//using &#58; for colon and &#63; for question mark and &#160; for space
output.Write("{0}&#58;&#160;{1}", "Access Result Cache Name", "<b>" + accessResultCache.InnerCache.Name + "</b></br/>");
output.Write("{0}&#63;&#160;{1}", "Access Result Cache Enabled", "<b>" + accessResultCache.InnerCache.Enabled.ToString() + "</b></br/>");
output.Write("{0}&#58;&#160;{1}", "Access Result Cache Maximum Size", "<b>" + accessResultCache.InnerCache.MaxSize.ToString() + "</b></br/>");
output.Write("{0}&#58;&#160;{1}", "Access Result Cache Size", "<b>" + accessResultCache.InnerCache.Size.ToString() + "</b></br/>");
output.Write("{0}&#58;&#160;{1}", "Access Result Cache Default Priority", "<b>" + accessResultCache.InnerCache.DefaultPriority.ToString() + "</b></br/>");
output.Write("{0}&#58;&#160;{1}", "Access Result Cache Space", "<b>" + accessResultCache.InnerCache.RemainingSpace.ToString() + "</b></br/>");
output.Write("{0}&#58;&#160;{1}", "Access Result Cache Count", "<b>" + accessResultCache.InnerCache.Count.ToString() + "</b></br/>");
output.Write("{0}&#63;&#160;{1}", "Access Result Cache Scavengable", "<b>" + accessResultCache.InnerCache.Scavengable.ToString() + "</b></br/>");
output.Write("{0}&#58;&#160;{1}", "Access Result Cache Sync Root", "<b>" + accessResultCache.InnerCache.SyncRoot.ToString() + "</b></br/>");

output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.P);
output.Write("{0}", "Is User In Role Cache");
output.RenderEndTag(); //P
//using &#58; for colon and &#63; for question mark and &#160; for space
output.Write("{0}&#58;&#160;{1}", "Is User In Role Cache Name", "<b>" + isInRoleCache.InnerCache.Name + "</b></br/>");
output.Write("{0}&#63;&#160;{1}", "Is User In Role Cache Enabled", "<b>" + isInRoleCache.InnerCache.Enabled.ToString() + "</b></br/>");
output.Write("{0}&#58;&#160;{1}", "Is User In Role Cache Maximum Size", "<b>" + isInRoleCache.InnerCache.MaxSize.ToString() + "</b></br/>");
output.Write("{0}&#58;&#160;{1}", "Is User In Role Cache Size", "<b>" + isInRoleCache.InnerCache.Size.ToString() + "</b></br/>");
output.Write("{0}&#58;&#160;{1}", "Is User In Role Cache Default Priority", "<b>" + isInRoleCache.InnerCache.DefaultPriority.ToString() + "</b></br/>");
output.Write("{0}&#58;&#160;{1}", "Is User In Role Cache Space", "<b>" + isInRoleCache.InnerCache.RemainingSpace.ToString() + "</b></br/>");
output.Write("{0}&#58;&#160;{1}", "Is User In Role Cache Count", "<b>" + isInRoleCache.InnerCache.Count.ToString() + "</b></br/>");
output.Write("{0}&#63;&#160;{1}", "Is User In Role Cache Scavengable", "<b>" + isInRoleCache.InnerCache.Scavengable.ToString() + "</b></br/>");
output.Write("{0}&#58;&#160;{1}", "Is User In Role Cache Sync Root", "<b>" + isInRoleCache.InnerCache.SyncRoot.ToString() + "</b></br/>");

output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.P);
output.Write("{0}", "User Profile Cache");
output.RenderEndTag(); //P
//using &#58; for colon and &#63; for question mark and &#160; for space
output.Write("{0}&#58;&#160;{1}", "User Profile Cache Name", "<b>" + userProfileCache.InnerCache.Name + "</b></br/>");
output.Write("{0}&#63;&#160;{1}", "User Profile Cache Enabled", "<b>" + userProfileCache.InnerCache.Enabled.ToString() + "</b></br/>");
output.Write("{0}&#58;&#160;{1}", "User Profile Cache Maximum Size", "<b>" + userProfileCache.InnerCache.MaxSize.ToString() + "</b></br/>");
output.Write("{0}&#58;&#160;{1}", "User Profile Cache Size", "<b>" + userProfileCache.InnerCache.Size.ToString() + "</b></br/>");
output.Write("{0}&#58;&#160;{1}", "User Profile Cache Default Priority", "<b>" + userProfileCache.InnerCache.DefaultPriority.ToString() + "</b></br/>");
output.Write("{0}&#58;&#160;{1}", "User Profile Cache Space", "<b>" + userProfileCache.InnerCache.RemainingSpace.ToString() + "</b></br/>");
output.Write("{0}&#58;&#160;{1}", "User Profile Cache Count", "<b>" + userProfileCache.InnerCache.Count.ToString() + "</b></br/>");
output.Write("{0}&#63;&#160;{1}", "User Profile Cache Scavengable", "<b>" + userProfileCache.InnerCache.Scavengable.ToString() + "</b></br/>");
output.Write("{0}&#58;&#160;{1}", "User Profile Cache Sync Root", "<b>" + userProfileCache.InnerCache.SyncRoot.ToString() + "</b></br/>");

output.RenderEndTag(); //Div


Cache Manager C# Web Control Output

Access Result Cache

Access Result Cache Name: AccessResultCache
Access Result Cache Enabled? True
Access Result Cache Maximum Size: 2097152
Access Result Cache Size: 142398
Access Result Cache Default Priority: Normal
Access Result Cache Space: 1954754
Access Result Cache Count: 2637
Access Result Cache Scavengable? False
Access Result Cache Sync Root: System.Object

Is User In Role Cache

Is User In Role Cache Name: IsUserInRoleCache
Is User In Role Cache Enabled? True
Is User In Role Cache Maximum Size: 1048576
Is User In Role Cache Size: 170
Is User In Role Cache Default Priority: Normal
Is User In Role Cache Space: 1048406
Is User In Role Cache Count: 5
Is User In Role Cache Scavengable? False
Is User In Role Cache Sync Root: System.Object

User Profile Cache

User Profile Cache Name: UserProfileCache
User Profile Cache Enabled? True
User Profile Cache Maximum Size: 1048576
User Profile Cache Size: 300
User Profile Cache Default Priority: Normal
User Profile Cache Space: 1048276
User Profile Cache Count: 6
User Profile Cache Scavengable? False
User Profile Cache Sync Root: System.Object

Sources