2012-04-19 10 views
5

Chcę wyczyścić pamięć podręczną Sitecore dla elementu programowo. Uruchomiłem poniższy kod. Potem próbowałem zrobić web.GetItem na usuniętym id i nadal otrzymuję wartość null. Jakieś sugestie?Wyczyść pamięć podręczną Sitecore dla elementu z pamięci podręcznej programowo

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

Odpowiedz

5

Wygląda pominięcia pamięci podręcznej pobierania wstępnego, oto jak się go:

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

A cache html również:

private void ClearAllHtmlCaches() 
{ 
    foreach (var info in Factory.GetSiteInfoList()) 
    { 
     info.HtmlCache.Clear(); 
    } 
} 
Powiązane problemy