예제 #1
0
        protected virtual async Task <IList <coreDto.SeoInfo> > GetAllSeoRecordsAsync(string slug)
        {
            var result = new List <coreDto.SeoInfo>();

            if (!string.IsNullOrEmpty(slug))
            {
                var cacheKey  = CacheKey.With(GetType(), "GetAllSeoRecords", slug);
                var apiResult = await _memoryCache.GetOrCreateExclusiveAsync(cacheKey, async (cacheEntry) =>
                {
                    cacheEntry.AddExpirationToken(RoutingCacheRegion.CreateChangeToken());
                    return(await _coreApi.GetSeoInfoBySlugAsync(slug));
                });

                result.AddRange(apiResult);
            }
            return(result);
        }
예제 #2
0
        protected virtual async Task <IDictionary <string, string> > GetFullSeoPathsAsync(string objectType, string[] objectIds, Store store, Language language)
        {
            var cacheKey = CacheKey.With(GetType(), "GetFullSeoPaths", store.Id, objectType, string.Join("-", objectIds.OrderBy(x => x)));

            return(await _memoryCache.GetOrCreateExclusiveAsync(cacheKey, async (cacheEntry) =>
            {
                cacheEntry.AddExpirationToken(RoutingCacheRegion.CreateChangeToken());
                cacheEntry.AddExpirationToken(_apiChangesWatcher.CreateChangeToken());
                switch (objectType)
                {
                case "Category":
                    return await GetCategorySeoPathsAsync(objectIds, store, language);

                case "CatalogProduct":
                    return await GetProductSeoPathsAsync(objectIds, store, language);
                }
                return new Dictionary <string, string>().WithDefaultValue(null);
            }));
        }