コード例 #1
0
ファイル: ContextPool.cs プロジェクト: g82tt/xcore
        public void Add(IEntity obj)
        {
            if (obj == null)
            {
                return;
            }

            String key = CacheKey.getObject(obj.GetType(), obj.Id);

            addToContext(key, obj);
            CacheTime.updateObject(obj);   // 加入缓存的时候,设置最新 timestamp
        }
コード例 #2
0
ファイル: ContextPool.cs プロジェクト: g82tt/xcore
 private void addList(String key, IList objList)
 {
     if (objList == null)
     {
         return;
     }
     addToContext(key, objList);
     foreach (IEntity obj in objList)
     {
         ContextCache.Put(CacheKey.getObject(obj.GetType(), obj.Id), obj);
     }
     CacheTime.updateList(key);
 }
コード例 #3
0
        public IEntity FindOne(Type t, int id)
        {
            String key = CacheKey.getObject(t, id);

            IEntity result = getFromApplication(key) as IEntity;

            if (result != null)
            {
                if (CacheTime.isObjectUpdated(result))
                {
                    return(null);                                     // 检查是否更新
                }
                logger.Info("APP_cache_get=>" + key);

                return(result);
            }

            return(null);
        }
コード例 #4
0
        //-----------------------------------------------------------

        public IList getListFromCache(String queryKey, Type t)
        {
            if (CacheTime.isListUpdate(queryKey, t))
            {
                return(null);
            }

            List <int> ids = appCache.Get(queryKey) as List <int>;

            if (ids == null)
            {
                return(null);
            }

            IList result = new ArrayList();

            foreach (int id in ids)
            {
                IEntity obj = this.findOnePrivate(t, id);

                if (obj == null)
                {
                    return(null);
                }

                if (CacheTime.isObjectUpdated(obj))
                {
                    return(null);                                  // 如果有任何一个对象更新过,则缓存失效
                }
                // 检查实体属性
                renewEntityPropertyValue(obj);

                result.Add(obj);
            }


            logger.Info("APP_cache_get=>" + queryKey);
            return(result);
        }
コード例 #5
0
        private static void addList(String key, IList objList)
        {
            if (objList == null)
            {
                return;
            }

            foreach (IEntity obj in objList)
            {
                addToApplication(CacheKey.getObject(obj.GetType(), obj.Id), obj);
                CacheTime.updateObject(obj);   // 加入缓存的时候,设置最新 timestamp
            }

            List <int> ids = new List <int>();

            foreach (IEntity obj in objList)
            {
                ids.Add(obj.Id);
            }
            addToApplication(key, ids);
            CacheTime.updateList(key);
        }
コード例 #6
0
 public void Delete(Type t, int id)
 {
     appCache.Remove(CacheKey.getObject(t.FullName, id));
     logger.Info("Delete=>" + t.FullName + id);
     CacheTime.updateTable(t);
 }