示例#1
0
        internal static void RemoveCategory(this ICategoryCache cache, ProfileFilter filter)
        {
            Ensure.Any.IsNotNull(cache, nameof(cache));
            Ensure.Any.IsNotNull(filter, nameof(filter));

            cache.RemoveCategory(filter.CategoryGroup, filter.CategoryName);
        }
示例#2
0
        internal static void RemoveCategory(this ICategoryCache cache, Category category)
        {
            Ensure.Any.IsNotNull(cache, nameof(cache));
            Ensure.Any.IsNotNull(category, nameof(category));

            cache.RemoveCategory(category.Group, category.Name);
        }
        private void UpdateCacheStore(ICollection <Category> categories, IEnumerable <ProfileFilter> filters)
        {
            // We either made changes to the category link count or a category was added
            // Store the new category list in the cache
            _cache.StoreCategories(categories);

            foreach (var filter in filters)
            {
                // Clear the cache to ensure that this profile is reflected in the category links on subsequent calls
                _cache.RemoveCategoryLinks(filter);

                // Remove the category from the cache
                _cache.RemoveCategory(filter);
            }
        }
示例#4
0
        private async Task StoreCategory(Category category, bool mustExist, CancellationToken cancellationToken)
        {
            var existingCategory = await _store.GetCategory(category.Group, category.Name, cancellationToken)
                                   .ConfigureAwait(false);

            if (existingCategory != null)
            {
                category.LinkCount = existingCategory.LinkCount;
            }
            else if (mustExist)
            {
                throw new NotFoundException();
            }

            category.Reviewed = true;

            await _store.StoreCategory(category, cancellationToken).ConfigureAwait(false);

            _cache.RemoveCategories();
            _cache.RemoveCategory(category);
        }