Beispiel #1
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);
        }
Beispiel #2
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);
        }