2012-04-19 24 views
5

Program öğesi olarak bir öğenin Sitecore önbelleğini temizlemek istiyorum. Aşağıdaki kodu çalıştırdım. Bundan sonra silinmiş bir kimlik üzerinde bir web.GetItem yapmayı denedim ve hala bir null aldım. Baska öneri?Önbellekten programlı olarak bir öğenin Sitecore önbelleğini temizle

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

cevap

5

Eğer önceden getirme önbellek kaçırmış gibi burada, Görünüşe nasıl olduğunu o:

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; 
      } 
     } 

Ve ayrıca html cache:

private void ClearAllHtmlCaches() 
{ 
    foreach (var info in Factory.GetSiteInfoList()) 
    { 
     info.HtmlCache.Clear(); 
    } 
} 
İlgili konular