I’m working on a site that requires the synchronisation of around 1000 content nodes to MYOB product data daily. In my quest to speed up the process I saw a post by Richard Soetman, developer of the excellent CMSImport package, where he advises to turn off the “ContinouslyUpdateXmlDiskCache” setting in umbracoSettings.config when performing bulk import operations.
I couldn’t find any code on how to do this, and being the .NET newbie that I am, it took me a little while to figure out. Here’s how I did it:
public static void SwitchContinuousUpdateOfXmlCacheState(bool newValue)
{
if (UmbracoSettings.continouslyUpdateXmlDiskCache == newValue) return;
var configFilePath = HttpContext.Current.Server.MapPath("~/config/umbracoSettings.config");
if (File.Exists(configFilePath))
{
var umbracoConfig = new XmlDocument();
umbracoConfig.Load(configFilePath);
var key = umbracoConfig.SelectSingleNode("//ContinouslyUpdateXmlDiskCache");
key.InnerText = newValue.ToString();
umbracoConfig.Save(configFilePath);
}
}
This way, I can toggle this setting off before performing the import, and then back on again after calling umbraco.library.RefreshContent();
I’m hoping this is the right approach. Feel free to let me know if it isn’t.