public static CachedFeaturedAd GetFeaturedAd(HttpContext context)
{
if (context == null)
return null;
int featureCacheNumber = random.Next(0, NumCachedFeatures - 1);
string cacheKey = GetCacheKey(featureCacheNumber);
CachedFeaturedAd feature = context.Cache[cacheKey] as CachedFeaturedAd;
if (feature == null)
{
feature = FetchFeaturedAd();
if (feature != null)
{
DateTime expiration = DateTime.Now.AddMinutes(CacheLifeTime);
context.Cache.Add(cacheKey, feature, null, expiration, TimeSpan.Zero, System.Web.Caching.CacheItemPriority.Normal, null);
}
}
return feature;
}