public override void Execute(CommandContext context) { XmlNode botrItemID = Sitecore.Configuration.Factory.GetConfigNode("/sitecore/dataProviders/botr/param[@desc='parentItem']"); if (botrItemID != null) { ItemCache itemCache = Sitecore.Context.ContentDatabase.Caches.ItemCache; DataCache dataCache = Sitecore.Context.ContentDatabase.Caches.DataCache; Item botrItem = Sitecore.Context.ContentDatabase.GetItem(botrItemID.InnerText); if (botrItem != null) { foreach (Item video in botrItem.GetChildren()) { itemCache.RemoveItem(video.ID); dataCache.RemoveItemInformation(video.ID); } itemCache.RemoveItem(botrItem.ID); dataCache.RemoveItemInformation(botrItem.ID); var cache = CacheManager.FindCacheByName(BotrDataProvider.CACHE_NAME); if (cache != null) { cache.Clear(); } Sitecore.Context.ClientPage.SendMessage(this, string.Format("item:refresh(id={0})", botrItem.ID)); Sitecore.Context.ClientPage.SendMessage(this, string.Format("item:refreshchildren(id={0})", botrItem.ID)); Sitecore.Context.ClientPage.SendMessage(this, string.Format("item:load(id={0})", botrItem.ID)); } } }
private void UpdateItemFromSource(ItemCache cache, Item sourceItem, Item targetItem) { cache.RemoveItem(sourceItem.ID); cache.RemoveItem(targetItem.ID); EnsureLayoutIsCopied(sourceItem, targetItem); cache.RemoveItem(targetItem.ID); _referenceUpdater.UpdateReferences(sourceItem, targetItem, targetItem.Branch?.InnerItem ?? sourceItem); cache.RemoveItem(targetItem.ID); }
public virtual void Process([NotNull] ProcessSharepointItemArgs args) { Assert.ArgumentNotNull(args, "args"); Assert.IsNotNull(args.SourceIntegrationItem, "args.SourceIntegrationItem"); ItemCache itemCache = CacheManager.GetItemCache(args.SourceIntegrationItem.Database); if (itemCache != null) { itemCache.RemoveItem(args.SourceIntegrationItem.ID); } DataCache dataCache = CacheManager.GetDataCache(args.SourceIntegrationItem.Database); if (dataCache != null) { dataCache.RemoveItemInformation(args.SourceIntegrationItem.ID); } var prefetchCache = this.GetPrefetchCache(args.SourceIntegrationItem.Database); if (prefetchCache != null) { prefetchCache.Remove(args.SourceIntegrationItem.ID); } args.SourceIntegrationItem = args.SourceIntegrationItem.Database.GetItem(args.SourceIntegrationItem.ID); if (args.SourceIntegrationItem == null) { string message = string.Format(LogMessages.SitecoreItem0IsDeletedAndCouldNotBeSynchronizedWithSharepoint, args.SharepointItem.UniqueID); Log.Warn(message, this); args.AbortPipeline(); } }
public static void TestRemoveCache() { CacheKey cacheKey = new CacheKey("a key").Subkey("a subkey").Subkey("another subkey"); int count = 0; ItemCache cache = new ItemCache(); object o = new object(); object item = cache.GetItem(cacheKey, () => { ++count; return(o); }); Assert.That(count, Is.EqualTo(1)); Assert.That(item, Is.EqualTo(o)); cache.RemoveItem(cacheKey); item = cache.GetItem(cacheKey, () => { ++count; return(new object()); }); Assert.That(count, Is.EqualTo(2)); Assert.That(item, Is.Not.EqualTo(o)); }
public static void TestFlushCache() { CacheKey cacheKey = new CacheKey("a key").Subkey("a subkey"); int count = 0; ItemCache cache = new ItemCache(); int item1 = cache.GetItem(cacheKey.Subkey("1"), () => { return(++count); }); Assert.That(item1, Is.EqualTo(1)); Assert.That(count, Is.EqualTo(1)); int item2 = cache.GetItem(cacheKey.Subkey("2"), () => { return(++count); }); Assert.That(item2, Is.EqualTo(2)); Assert.That(count, Is.EqualTo(2)); item1 = cache.GetItem(cacheKey.Subkey("1"), () => { return(++count); }); Assert.That(item1, Is.EqualTo(1)); Assert.That(count, Is.EqualTo(2)); item2 = cache.GetItem(cacheKey.Subkey("2"), () => { return(++count); }); Assert.That(item2, Is.EqualTo(2)); Assert.That(count, Is.EqualTo(2)); cache.RemoveItem(CacheKey.RootKey); item1 = cache.GetItem(cacheKey.Subkey("1"), () => { return(++count); }); Assert.That(item1, Is.EqualTo(3)); Assert.That(count, Is.EqualTo(3)); item2 = cache.GetItem(cacheKey.Subkey("2"), () => { return(++count); }); Assert.That(item2, Is.EqualTo(4)); Assert.That(count, Is.EqualTo(4)); item1 = cache.GetItem(cacheKey.Subkey("1"), () => { return(++count); }); Assert.That(item1, Is.EqualTo(3)); Assert.That(count, Is.EqualTo(4)); item2 = cache.GetItem(cacheKey.Subkey("2"), () => { return(++count); }); Assert.That(item2, Is.EqualTo(4)); Assert.That(count, Is.EqualTo(4)); }
protected void EditConflicts(ID tagID, ID conflictID, bool addConflict) { Database currentDb = Sitecore.Context.ContentDatabase ?? Sitecore.Context.Database; if (currentDb != null) { Item editItem = currentDb.GetItem(tagID); if (editItem != null) { List <string> conflictTags = new List <string>(); if (string.IsNullOrEmpty(editItem[conflictFieldName]) && addConflict) { conflictTags.Add(conflictID.ToString()); } else { conflictTags.AddRange(editItem[conflictFieldName].Split('|').ToList()); if (addConflict) { conflictTags.Add(conflictID.ToString()); } else { conflictTags.Remove(conflictID.ToString()); } } using (new SecurityDisabler()) { using (new EditContext(editItem, true, true)) { editItem[conflictFieldName] = StringUtil.Join(conflictTags, "|"); } ItemCache cache = CacheManager.GetItemCache(Client.ContentDatabase); cache.RemoveItem(editItem.ID); } } } }
public override void RemoveObject(byte objectType, string objectId) { ItemCache.RemoveItem(objectType, objectId); }