Beispiel #1
0
 public static void RemoveCache(string tableName, int channelId)
 {
     ListCache.Remove(channelId);
     ContentCache.Remove(channelId);
     CountCache.Clear(tableName);
     StlContentCache.ClearCache();
 }
Beispiel #2
0
        public static void UpdateCache(SiteInfo siteInfo, ChannelInfo channelInfo, IContentInfo contentInfoToUpdate)
        {
            var dict = ContentCache.GetContentDict(channelInfo.Id);

            var contentInfo = GetContentInfo(siteInfo, channelInfo, contentInfoToUpdate.Id);

            if (contentInfo != null)
            {
                var isClearCache = contentInfo.IsTop != contentInfoToUpdate.IsTop;

                if (!isClearCache)
                {
                    var orderAttributeName =
                        ETaxisTypeUtils.GetContentOrderAttributeName(
                            ETaxisTypeUtils.GetEnumType(channelInfo.Additional.DefaultTaxisType));
                    if (contentInfo.Get(orderAttributeName) != contentInfoToUpdate.Get(orderAttributeName))
                    {
                        isClearCache = true;
                    }
                }

                if (isClearCache)
                {
                    ListCache.Remove(channelInfo.Id);
                }
            }


            dict[contentInfoToUpdate.Id] = (ContentInfo)contentInfoToUpdate;

            StlContentCache.ClearCache();
        }
        public static void UpdateCache(SiteInfo siteInfo, ChannelInfo channelInfo, ContentInfo contentInfoToUpdate)
        {
            var dict = ContentCache.GetContentDict(channelInfo.Id);

            var contentInfo = GetContentInfo(siteInfo, channelInfo, contentInfoToUpdate.Id);

            if (contentInfo != null)
            {
                if (ListCache.IsChanged(channelInfo, contentInfo, contentInfoToUpdate))
                {
                    ListCache.Remove(channelInfo.Id);
                }

                if (CountCache.IsChanged(contentInfo, contentInfoToUpdate))
                {
                    var tableName = ChannelManager.GetTableName(siteInfo, channelInfo);
                    CountCache.Remove(tableName, contentInfo);
                    CountCache.Add(tableName, contentInfoToUpdate);
                }
            }

            dict[contentInfoToUpdate.Id] = contentInfoToUpdate;

            StlContentCache.ClearCache();
        }
Beispiel #4
0
        public void should_remove_item()
        {
            // Arrange
            CacheMock           cache    = new CacheMock();
            ApplicationSettings settings = new ApplicationSettings()
            {
                UseObjectCache = true
            };

            List <string> tagCacheItems = new List <string>()
            {
                "1", "2"
            };

            AddToCache(cache, "all.tags", tagCacheItems);

            ListCache listCache = new ListCache(settings, cache);

            // Act
            listCache.Remove("all.tags");

            // Assert
            var tags = cache.CacheItems.FirstOrDefault();

            Assert.That(tags, Is.Null);
        }
 public void OnUpdate(Sql cond)
 {
     ListCache.Remove(CombineCacheKey(cond));
     if (!cond.Disposed)
     {
         cond.Dispose();
     }
 }
 public static void RemoveCacheBySiteId(string tableName, int siteId)
 {
     foreach (var channelId in ChannelManager.GetChannelIdList(siteId))
     {
         ListCache.Remove(channelId);
         ContentCache.Remove(channelId);
     }
     CountCache.Clear(tableName);
     StlContentCache.ClearCache();
 }
Beispiel #7
0
        public static void UpdateCache(SiteInfo siteInfo, ChannelInfo channelInfo, ContentInfo contentInfo)
        {
            var dict = ContentCache.GetContentDict(channelInfo.Id);

            ListCache.Remove(channelInfo.Id);

            var tableName = ChannelManager.GetTableName(siteInfo, channelInfo);

            CountCache.Remove(tableName, contentInfo);
            CountCache.Add(tableName, contentInfo);

            dict[contentInfo.Id] = contentInfo;

            StlContentCache.ClearCache();
        }
Beispiel #8
0
        /// <summary>
        /// Renames a tag by changing all pages that reference the tag to use the new tag name.
        /// </summary>
        /// <exception cref="DatabaseException">An databaseerror occurred while saving one of the pages.</exception>
        /// <exception cref="SearchException">An error occurred updating the search index.</exception>
        public void RenameTag(string oldTagName, string newTagName)
        {
            if (string.IsNullOrEmpty(oldTagName) || string.IsNullOrEmpty(newTagName))
            {
                return;
            }

            try
            {
                IEnumerable <PageViewModel> pageModels = FindByTag(oldTagName);

                foreach (PageViewModel model in pageModels)
                {
                    _searchService.Delete(model);

                    string tags = model.CommaDelimitedTags();

                    if (tags.IndexOf(",") != -1)
                    {
                        tags = tags.Replace(oldTagName + ",", newTagName + ",");
                    }
                    else if (tags.IndexOf(";") != -1)
                    {
                        // legacy
                        tags = tags.Replace(oldTagName + ";", newTagName + ";");
                    }
                    else
                    {
                        // Single tag
                        tags = tags.Replace(oldTagName, newTagName);
                    }

                    model.RawTags = tags;
                    UpdatePage(model);
                }

                string cacheKey = CacheKeys.PagesByTagKey(oldTagName);
                _listCache.Remove(cacheKey);
            }
            catch (DatabaseException ex)
            {
                throw new DatabaseException(ex, "An error occurred while changing the tagname {0} to {1}", oldTagName, newTagName);
            }
        }
Beispiel #9
0
        public static void InsertCache(SiteInfo siteInfo, ChannelInfo channelInfo, IContentInfo contentInfo)
        {
            if (contentInfo.SourceId == SourceManager.Preview)
            {
                return;
            }

            var contentIdList = ListCache.GetContentIdList(channelInfo.Id);

            if (ETaxisTypeUtils.Equals(ETaxisType.OrderByTaxisDesc, channelInfo.Additional.DefaultTaxisType))
            {
                contentIdList.Insert(0, contentInfo.Id);
            }
            else
            {
                ListCache.Remove(channelInfo.Id);
            }

            var dict = ContentCache.GetContentDict(contentInfo.ChannelId);

            dict[contentInfo.Id] = (ContentInfo)contentInfo;

            var tableName     = ChannelManager.GetTableName(siteInfo, channelInfo);
            var countInfoList = GetContentCountInfoList(tableName);
            var countInfo     = countInfoList.FirstOrDefault(x =>
                                                             x.SiteId == siteInfo.Id && x.ChannelId == channelInfo.Id &&
                                                             x.IsChecked == contentInfo.IsChecked.ToString() && x.CheckedLevel == contentInfo.CheckedLevel);

            if (countInfo != null)
            {
                countInfo.Count++;
            }

            StlContentCache.ClearCache();
            CountCache.Clear(tableName);
        }
Beispiel #10
0
		public void Should_Remove_Item()
		{
			// Arrange
			CacheMock cache = new CacheMock();
			ApplicationSettings settings = new ApplicationSettings() { UseObjectCache = true };

			List<string> tagCacheItems = new List<string>() { "1", "2" };
			AddToCache(cache, "all.tags", tagCacheItems);

			ListCache listCache = new ListCache(settings, cache);

			// Act
			listCache.Remove("all.tags");

			// Assert
			var tags = cache.CacheItems.FirstOrDefault();
			Assert.That(tags, Is.Null);
		}
 public void OnUpdate <V>(string col, V val, string orderby = null, uint count = 1000)
 {
     ListCache.Remove(CombineCacheKey(col, val, orderby, count));
 }
 public void OnUpdate(T bean, string orderby = null, uint count = 1000)
 {
     ListCache.Remove(CombineCacheKey(bean, orderby, count));
 }