Project Kavo
ExtendedProductCategoryManager
/// Ticket 88704: [Kavo] 3.9. PDP – RELATED ITEMS /// <summary> /// Get product categories by product child level. /// </summary> /// <param name="level">product's child level</param> /// <returns></returns> public virtual IProductCategoryCollection GetProductCategoriesByLevel(int level) { bool fromCache; var categories = CacheManager.FromCache(ErpCollectionCacheKey<IProductCategory>() + "CategoriesByLevel" + level, () => ((ExtendedOfflineProductCategoryProvider)Provider).GetProductCategoriesByLevel(level), out fromCache); return categories; }
use a unique key for cacheKey
/// Ticket 88704: [Kavo] 3.9. PDP – RELATED ITEMS /// <summary> /// Get related product item. /// </summary> /// <param name="categoryId"></param> /// <returns></returns> public virtual IRelatedProductSet GetRelatedProductSetByCategoryId(string categoryId) { var cacheKey = CacheKey.ForContentCollection<IRelatedProductSet>(categoryId); var list = CommerceFrameworkBase.Content.GetContentCacheContainer() .FromCache(cacheKey, () => ((ExtendedOfflineProductProvider)Provider).GetRelatedProductSetByCategoryId(categoryId)); return list; }
cache with List exampe.
ExtendedProductManager
/// Ticket 88704: [Kavo] 3.9. PDP – RELATED ITEMS /// <summary> /// Get related product items by category ids. /// </summary> /// <param name="categoryId">category id</param> /// <returns>related product item</returns> public virtual IList<IRelatedProductSet> GetRelatedProductSetsByCategoryIds(List<string> categoryIdList) { string categoryIdListString = string.Join(" ", categoryIdList.ToArray()); var cacheKey = CacheKey.ForContentCollection<IRelatedProductSet>(categoryIdListString); var list = CommerceFrameworkBase.Content.GetContentCacheContainer() .FromCache(cacheKey, () => ((ExtendedOfflineProductProvider)Provider).GetRelatedProductSetsByCategoryIds(categoryIdList)); return list; }
another simple way to cache
ExtendedCommonManager
public IPIMModelsDataCollection GetPIMModels(string makeId) { var key = CacheKey.ForContentCollection<PIMModelsData>() + "PIMModels" + makeId; return CacheManager.FromCache(key, () => ((ExtendedOfflineCommonProvider)Providers.Offline.Common).GetPIMModels(makeId)); }
public IPIMMakesDataCollection GetPIMMakes() { var key = CacheKey.ForContentCollection<PIMMakesData>() + "PIMMakes"; return CacheManager.FromCache(key, () => ((ExtendedOfflineCommonProvider)Providers.Offline.Common).GetPIMModels()); }