Exemple #1
0
 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.
     }
 }
Exemple #2
0
        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);
        }
Exemple #3
0
        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);
            }
        }
Exemple #4
0
        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);
        }
Exemple #5
0
        public static IEnumerable <NoteInfo> Get(string room_name)
        {
            NoteRoll roll = get(room_name);

            return(roll.Get());
        }