public void RemoveFromCache() { var htmlCacheKey = GetCacheKey(RenderVersion.HTML); var mobileCacheKey = GetCacheKey(RenderVersion.Mobile); FileCacheHelper.RemoveFromCache(htmlCacheKey); RedisCacheHelper.RemoveFromCache(htmlCacheKey); ContextHelper.RemoveFromCache(htmlCacheKey); RedisCacheHelper.RemoveFromCache(mobileCacheKey); FileCacheHelper.RemoveFromCache(mobileCacheKey); ContextHelper.RemoveFromCache(mobileCacheKey); /*var language = this.Language; * * if(language == null && this.LanguageID > 0) * { * language = LanguagesMapper.GetByID(this.LanguageID); * }*/ var parents = GetAllParentMediaDetails(this.LanguageID).Where(i => i.ID != this.ID); foreach (var item in parents) { item.RemoveFromCache(); } }
public dynamic GetTweetsByScreenName(string screenName, int count = 2, bool returnRawResults = false) { var key = "HomeTweets"; var rawResultsKey = "RawResultHomeTweets"; var homeTweets = (List <LinqToTwitter.Status>)ContextHelper.GetFromCache(key); var rawResults = (string)ContextHelper.GetFromCache(rawResultsKey); if ((returnRawResults) && (!string.IsNullOrEmpty(rawResults))) { return(rawResults); } if (homeTweets != null) { return(homeTweets); } try { var twitterContext = new TwitterContext(GetOAuthToken()); var queryResults = (from tweet in twitterContext.Status where tweet.Type == StatusType.User && tweet.ScreenName == screenName && tweet.Count == count && tweet.IncludeRetweets == true select tweet); var queryResultsList = queryResults.ToList(); ContextHelper.SaveToCache(key, queryResultsList, DateTime.Now.AddMinutes(10)); ContextHelper.SaveToCache(rawResultsKey, twitterContext.RawResult, DateTime.Now.AddMinutes(10)); if (returnRawResults) { return(twitterContext.RawResult); } else { return(queryResultsList); } } catch (Exception ex) { ErrorHelper.LogException(ex); ContextHelper.RemoveFromCache(key); } return(homeTweets); }
public static Return RemoveFromCache(string url) { try { var fileInfo = GetFileInfoFromUrl(url); if (fileInfo.Exists) { File.Delete(fileInfo.FullName); ContextHelper.RemoveFromCache(url); fileInfo.Directory.Delete(true); } return(new Return()); } catch (Exception ex) { ErrorHelper.LogException(ex); return(new Return(ex, ErrorHelper.CreateError(ex))); } }