Created
May 14, 2013 03:17
-
-
Save DaveGoosem/5573418 to your computer and use it in GitHub Desktop.
Clearing Sitecore Cache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Database db = new Database("web"); | |
if (ID.IsID(id)) | |
{ | |
ID itemID = new ID(id); | |
//clear data cache | |
db.Caches.DataCache.RemoveItemInformation(itemID); | |
//clear item cache | |
db.Caches.ItemCache.RemoveItem(itemID); | |
//clear standard values cache | |
db.Caches.StandardValuesCache.RemoveKeysContaining(itemID.ToString()); | |
//remove path cache | |
db.Caches.PathCache.RemoveKeysContaining(itemID.ToString()); | |
} | |
private Cache GetPrefetchCache(Database database) | |
{ | |
foreach (var cache in global::Sitecore.Caching.CacheManager.GetAllCaches()) | |
{ | |
if (cache.Name.Contains(string.Format("Prefetch data({0})", database.Name))) | |
{ | |
return cache; | |
} | |
} | |
} | |
private void ClearAllHtmlCaches() | |
{ | |
foreach (var info in Factory.GetSiteInfoList()) | |
{ | |
info.HtmlCache.Clear(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment