Skip to content

Commit

Permalink
Invalidate the menu links data from the cache by changing the data in…
Browse files Browse the repository at this point in the history
… the platform.
  • Loading branch information
tatarincev committed Dec 5, 2017
1 parent 5ecfb13 commit 1416770
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using VirtoCommerce.Storefront.Model.LinkList.Services;
using VirtoCommerce.Storefront.Model.Services;
using VirtoCommerce.Storefront.Model.Stores;
using VirtoCommerce.Storefront.Infrastructure;

namespace VirtoCommerce.Storefront.Domain
{
Expand All @@ -20,12 +21,13 @@ public class MenuLinkListServiceImpl : IMenuLinkListService
private readonly IMenu _cmsApi;
private readonly ICatalogService _catalogService;
private readonly IMemoryCache _memoryCache;

public MenuLinkListServiceImpl(IMenu cmsApi, ICatalogService catalogService, IMemoryCache memoryCache)
private readonly IApiChangesWatcher _apiChangesWatcher;
public MenuLinkListServiceImpl(IMenu cmsApi, ICatalogService catalogService, IMemoryCache memoryCache, IApiChangesWatcher apiChangesWatcher)
{
_cmsApi = cmsApi;
_catalogService = catalogService;
_memoryCache = memoryCache;
_apiChangesWatcher = apiChangesWatcher;
}

public async Task<IList<MenuLinkList>> LoadAllStoreLinkListsAsync(Store store, Language language)
Expand All @@ -38,6 +40,8 @@ public async Task<IList<MenuLinkList>> LoadAllStoreLinkListsAsync(Store store, L
return await _memoryCache.GetOrCreateExclusiveAsync(cacheKey, async (cacheEntry) =>
{
cacheEntry.AddExpirationToken(StaticContentCacheRegion.CreateChangeToken());
cacheEntry.AddExpirationToken(_apiChangesWatcher.CreateChangeToken());

var result = new List<MenuLinkList>();
var listsDto = await _cmsApi.GetListsAsync(store.Id);
if(listsDto != null)
Expand Down

0 comments on commit 1416770

Please sign in to comment.