Ejemplo n.º 1
0
 private void removedCallback(string key, Object value, CacheItemRemovedReason reason)
 {
     if (reason == CacheItemRemovedReason.Expired)
     {
         BlockPathsRoll obj = (BlockPathsRoll)value;
         // insertNew(key);		// Not needed to keep it always in memory.
     }
 }
Ejemplo n.º 2
0
        private BlockPathsRoll insertNew(string key)
        {
            BlockPathsRoll obj = new BlockPathsRoll(key);                       // if concurrency happens, this will be done more than once.

            // todo: should put empty blocks into cache for ?

            HttpRuntime.Cache.Insert(key, 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);
        }
Ejemplo n.º 3
0
        private BlockPathsRoll get(int block_idx_x, int block_idx_y)
        {
            // be careful of name conflict from other ponds using the same cache.
            string key = Config.DRAWING_PAR_KEY_PREFIX + block_idx_x.ToString() + ',' + block_idx_y.ToString();

            BlockPathsRoll obj = (BlockPathsRoll)HttpRuntime.Cache.Get(key);

            if (obj == null)
            {
                obj = insertNew(key);
            }

            return(obj);
        }
Ejemplo n.º 4
0
        public int AddPath(PathModel model)
        {
            int ret = DrawingStore.AddPath(model);

            if (ret == 0 || ret == 3)
            {
                string         key = Config.DRAWING_PAR_KEY_PREFIX + model.BlockIndexX.ToString() + ',' + model.BlockIndexY.ToString();
                BlockPathsRoll obj = (BlockPathsRoll)HttpRuntime.Cache.Get(key);

                if (obj != null)
                {
                    obj.AddPath(model);
                }
            }
            return(ret);
        }
Ejemplo n.º 5
0
        public IEnumerable <PathModel> GetBlockPaths(int block_idx_x, int block_idx_y)
        {
            BlockPathsRoll roll = this.get(block_idx_x, block_idx_y);

            return(roll.Get());
        }