private static void removedCallback(string key, Object value, CacheItemRemovedReason reason) { if (reason == CacheItemRemovedReason.Expired) { NoteRoll obj = (NoteRoll)value; // insertNew(key); // Not needed to keep it always in memory. } }
private static NoteRoll insertNew(string room_name) { NoteRoll obj = new NoteRoll(room_name); // if concurrency happens, this will be done more than once. HttpRuntime.Cache.Insert(key(room_name), obj, null, DateTime.Now.AddSeconds(Config.DEFAULT_CACHE_SECONDS), Cache.NoSlidingExpiration, CacheItemPriority.Default, removedCallback); // expires after some time for multi-node synchronization (unreliable). return(obj); }
public static void AddNote(string room_name, NoteInfo info) { NoteStore.AddNote(room_name, info); NoteRoll obj = (NoteRoll)HttpRuntime.Cache.Get(key(room_name)); if (obj != null) { obj.AddNote(info); } }
private static NoteRoll get(string room_name) { NoteRoll obj = (NoteRoll)HttpRuntime.Cache.Get(key(room_name)); if (obj == null) { obj = insertNew(room_name); } return(obj); }
public static IEnumerable <NoteInfo> Get(string room_name) { NoteRoll roll = get(room_name); return(roll.Get()); }