Data Provider Caching

Data Provider Caching

Data Provider Caching

  • Use the CacheOptions property for the DataProvider base class to enable caching for that data provider
  • Set the CacheOptions.DisableAll to false
  • This configuration setting is for the file system data provider

Configuration Settings

<dataProviders>

        <main type="Sitecore.Data.$(database).$(database)DataProvider, Sitecore.Kernel">
            <param connectionStringName="$(1)" />
            <Name>$(1)</Name>
      </main>
      <filesystem type="Sitecore.Data.DataProviders.FileSystemDataProvider, Sitecore.Kernel">
            <CacheOptions.DisableAll>true</CacheOptions.DisableAll>
      </filesystem>
      <templatefile type="Sitecore.Data.DataProviders.TemplateFileResolver, Sitecore.Kernel">
            <param desc="template file">$(1)</param>
            <abortChain>true</abortChain>
      </templatefile>

</dataProviders>


C# Web Control Code

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

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();

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 &#58; for colon and &#160; for space
output.Write("{0}&#58;&#160;{1}", "Item", item.DisplayName);
output.RenderEndTag(); //P

string dataProviderTimeout = Sitecore.Configuration.Settings.DataProviderTimeout.ToString(); ;
output.Write("{0}&#58;&#160;{1}", "Data Provider Timeout", "<b>" + dataProviderTimeout + "</b>");

output.RenderEndTag(); //Div