public static List<CachedCategory> GetCategoriesByParentId(HttpContext context, int parentCategoryId, bool updateFrequently)
{
string cacheKey = (updateFrequently ? "BR" : "SC") + parentCategoryId.ToString();
DateTime expiration = updateFrequently ? DateTime.Now.AddSeconds(1) : DateTime.Now.AddDays(1);
List<CachedCategory> subCategories = context.Cache[cacheKey] as List<CachedCategory>;
if (subCategories == null)
{
subCategories = FetchCategoriesByParentId(parentCategoryId);
CacheDependency watchAllCategoriesKey = new System.Web.Caching.CacheDependency(null, AllCategoriesKeyArrayWrap);
context.Cache.Add(cacheKey, subCategories, watchAllCategoriesKey, expiration, TimeSpan.Zero, System.Web.Caching.CacheItemPriority.Normal, null);
}
return subCategories;
}