예제 #1
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);
        }
예제 #2
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);
        }
예제 #3
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);
        }
예제 #4
0
        public static void CachingObject <T>(string routingName, IFilterCondition[] where, T target)
            where T : class, IAlbianObject
        {
            ICacheAttribute cache = GetCacheAttribute(target);

            if (null == cache || !cache.Enable)
            {
                return;
            }
            string cachedKey = null != where && 1 == where.Length && "id" == where[0].PropertyName.ToLower()
                                   ? Utils.GetCacheKey <T>(where[0].Value.ToString(), AssemblyManager.GetFullTypeName(target)) //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;
            }
            cachedService.InsertOrUpdate(cachedKey, target, cache.LifeTime);
        }