コード例 #1
0
        public static IList <T> GetCachingObjects <T>(IDbCommand cmd)
            where T : class, IAlbianObject
        {
            ICacheAttribute cache = GetCacheAttribute <T>();

            if (null == cache || !cache.Enable)
            {
                return(null);
            }
            string         cachedKey     = Utils.GetCacheKey <T>(cmd);
            IExpiredCached cachedService = AlbianServiceRouter.GetService <IExpiredCached>();

            if (null == cachedService)
            {
                if (null != Logger)
                {
                    Logger.Warn("No expired cached service.");
                }
                return(null);
            }
            object oTarget = cachedService.Get(cachedKey);

            if (null == oTarget)
            {
                return(null);
            }
            return((IList <T>)oTarget);
        }
コード例 #2
0
        public static IList <T> GetCachingObjects <T>(string routingName, int top, IFilterCondition[] where,
                                                      IOrderByCondition[] orderby)
            where T : class, IAlbianObject
        {
            ICacheAttribute cache = GetCacheAttribute <T>();

            if (null == cache || !cache.Enable)
            {
                return(null);
            }
            string         cachedKey     = Utils.GetCacheKey <T>(routingName, top, where, orderby);
            IExpiredCached cachedService = AlbianServiceRouter.GetService <IExpiredCached>();

            if (null == cachedService)
            {
                if (null != Logger)
                {
                    Logger.Warn("No expired cached service.");
                }
                return(null);
            }
            object oTarget = cachedService.Get(cachedKey);

            if (null == oTarget)
            {
                return(null);
            }
            return((IList <T>)oTarget);
        }
コード例 #3
0
        public static T GetCachingObject <T>(string routingName, IFilterCondition[] where)
            where T : class, IAlbianObject
        {
            ICacheAttribute cache = GetCacheAttribute <T>();

            if (null == cache || !cache.Enable)
            {
                return(null);
            }
            string cachedKey = null != where && 1 == where.Length && "id" == where[0].PropertyName.ToLower()
                                   ? Utils.GetCacheKey <T>(where[0].Value.ToString(), AssemblyManager.GetFullTypeName <T>()) //find by pk id
                                   : Utils.GetCacheKey <T>(routingName, 0, where, null);

            IExpiredCached cachedService = AlbianServiceRouter.GetService <IExpiredCached>();

            if (null == cachedService)
            {
                if (null != Logger)
                {
                    Logger.Warn("No expired cached service.");
                }
                return(null);
            }
            object oTarget = cachedService.Get(cachedKey);

            if (null == oTarget)
            {
                return(null);
            }
            return((T)oTarget);
        }
コード例 #4
0
        public static void CachingObjects <T>(IDbCommand cmd, IList <T> target)
            where T : class, IAlbianObject
        {
            ICacheAttribute cache = GetCacheAttribute <T>();

            if (null == cache || !cache.Enable)
            {
                return;
            }
            string         cachedKey     = Utils.GetCacheKey <T>(cmd);
            IExpiredCached cachedService = AlbianServiceRouter.GetService <IExpiredCached>();

            if (null == cachedService)
            {
                if (null != Logger)
                {
                    Logger.Warn("No expired cached service.");
                }
                return;
            }
            cachedService.InsertOrUpdate(cachedKey, target, cache.LifeTime);
        }
コード例 #5
0
        public static void CachingObject <T>(T target)
            where T : class, IAlbianObject
        {
            ICacheAttribute cacheAttr = GetCacheAttribute(target);

            if (null == cacheAttr || !cacheAttr.Enable)
            {
                return;
            }
            string         cachedKey     = Utils.GetCacheKey <T>(target.Id, AssemblyManager.GetFullTypeName(target));
            IExpiredCached cachedService = AlbianServiceRouter.GetService <IExpiredCached>();

            if (null == cachedService)
            {
                if (null != Logger)
                {
                    Logger.Warn("No expired cached service.");
                }
                return;
            }
            cachedService.InsertOrUpdate(cachedKey, target, cacheAttr.LifeTime);
        }
コード例 #6
0
 public static void CheckCountCache(String action, IEntity obj, EntityInfo entityInfo)
 {
     for (int i = 0; i < entityInfo.SavedPropertyList.Count; i++)
     {
         IEntity            container    = null;
         String             propertyName = null;
         EntityPropertyInfo info         = entityInfo.SavedPropertyList[i];
         if ((info.Name != "Id") && !(info.Name == "OID"))
         {
             ICacheAttribute attribute = ReflectionUtil.GetAttribute(info.Property, typeof(CacheCountAttribute)) as ICacheAttribute;
             if (attribute != null)
             {
                 container    = ReflectionUtil.GetPropertyValue(obj, info.Name) as IEntity;
                 propertyName = attribute.TargetPropertyName.Replace(" ", "");
             }
             if (container != null)
             {
                 String columnName = Entity.GetInfo(container).GetColumnName(propertyName);
                 setCountCacheBySql(container, columnName, action);
             }
         }
     }
 }
コード例 #7
0
        public static void CachingObjects <T>(string routingName, int top, IFilterCondition[] where,
                                              IOrderByCondition[] orderby, IList <T> target)
            where T : class, IAlbianObject
        {
            ICacheAttribute cache = GetCacheAttribute <T>();

            if (null == cache || !cache.Enable)
            {
                return;
            }
            string         cachedKey     = Utils.GetCacheKey <T>(routingName, top, where, orderby);
            IExpiredCached cachedService = AlbianServiceRouter.GetService <IExpiredCached>();

            if (null == cachedService)
            {
                if (null != Logger)
                {
                    Logger.Warn("No expired cached service.");
                }
                return;
            }
            cachedService.InsertOrUpdate(cachedKey, target, cache.LifeTime);
        }