private void removedCallback(string key, Object value, CacheItemRemovedReason reason) { if (reason == CacheItemRemovedReason.Expired) { DiscussionList obj = (DiscussionList)value; insertNew(key, obj.BoardId); } }
public void Notify(string board_id) { string key = SandId.CombineId("dlpond1", board_id); DiscussionList obj = (DiscussionList)HttpRuntime.Cache.Remove(key); if (obj != null) { insertNew(key, obj.BoardId); } }
private DiscussionList insertNew(string key, string board_id) { DiscussionList obj = new DiscussionList(board_id); // if concurrency happens, this will be done more than once. HttpRuntime.Cache.Insert(key, obj, null, DateTime.Now.AddSeconds(HeartsConfiguration.DEFAULT_CACHE_SECONDS), Cache.NoSlidingExpiration, CacheItemPriority.Default, removedCallback); // expires after some time for multi-node synchronization (unreliable). return(obj); }
public DiscussionList Get(string board_id) { string key = SandId.CombineId("dlpond1", board_id); DiscussionList obj = (DiscussionList)HttpRuntime.Cache.Get(key); if (obj == null) { obj = insertNew(key, board_id); } return(obj); }
public override void ExecuteResult(ControllerContext context) { TextWriter writer = context.HttpContext.Response.Output; //using (JsonTextWriter writer = new JsonTextWriter(context.HttpContext.Response.Output)) //{ if (selectionId != null) { //string selection_name = SelectionInfoStore.GetSelectionName(this.selectionId); string selection_name = Warehouse.BsMapPond.Get().GetSelectionName(this.selectionId); //writer.WritePropertyName("selection_name"); //writer.WriteValue(selection_name); writer.WriteForCrawler("h1", selection_name); } foreach (string board_id in this.boardList) { DiscussionList dl = Warehouse.DiscussionListPond.Get(board_id); dl.Write(writer); } //} //base.ExecuteResult(context); }