Skip to content

Commit

Permalink
Added invalidation for the contest category service model.
Browse files Browse the repository at this point in the history
  • Loading branch information
deyordanov committed Dec 2, 2024
1 parent 3b758af commit d6f8ab4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public override async Task<ContestCategoryAdministrationModel> Edit(ContestCateg

await this.ReevaluateContestCategoriesOrder(contestCategory);
await this.contestCategoriesCache.ClearMainContestCategoriesCache();
await this.contestCategoriesCache.ClearContestCategoryDetailsCache(contestCategory.Id);
return model;
}

Expand All @@ -153,6 +154,7 @@ await Task.WhenAll(

this.categoriesDataService.Delete(contestCategory);
await this.contestCategoriesCache.ClearMainContestCategoriesCache();
await this.contestCategoriesCache.ClearContestCategoryDetailsCache(contestCategory.Id);
await this.categoriesDataService.SaveChanges();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ public interface IContestCategoriesCacheService : IService
Task ClearMainContestCategoriesCache();

Task ClearContestCategoryParentsAndChildren(int categoryId);

Task ClearContestCategoryDetailsCache(int categoryId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public ContestCategoriesCacheService(
public async Task ClearMainContestCategoriesCache()
=> await this.cache.Remove(CacheConstants.ContestCategoriesTree);

public async Task ClearContestCategoryDetailsCache(int categoryId)
=> await this.cache.Remove(string.Format(CacheConstants.ContestCategoryDetails, categoryId));

public async Task ClearContestCategoryParentsAndChildren(int categoryId)
{
var contestCategory = await this.contestCategoriesData
Expand Down

0 comments on commit d6f8ab4

Please sign in to comment.