Exemple #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);
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #6
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);
        }