Пример #1
0
        /// <summary>
        /// 批量操作缓存
        /// </summary>
        /// <param name="result"></param>
        /// <returns></returns>
        private List <Bank> MappingCacheEntity(List <int> result)
        {
            //exists result is null(empty)
            if (result != null && result.Count > 0)
            {
                String      key          = string.Empty;
                Bank        cache        = null;
                List <Bank> result_cache = new List <Bank>(result.Count);

                foreach (var item in result)
                {
                    key   = EncodeKey("ID", item);
                    cache = Memcache.Get(key) as Bank;
                    if (cache == null)
                    {
                        cache = Single(item);
                        Memcache.Store(key, cache, DurationCache);
                    }

                    if (cache != null)
                    {
                        result_cache.Add(cache);
                    }
                }
                return(result_cache);
            }
            return(null);
        }
Пример #2
0
        /// <summary>
        /// 根据主键ID取得单一实体,如果没有找到则返回null
        /// </summary>
        /// <param name="id">实体的主键ID</param>
        /// <returns>Channel实体对象</returns>
        public Channel Single(int id)
        {
            var key    = EncodeKey("CId", id);
            var result = Memcache.Get(key) as Channel;

            if (result == null)
            {
                result = base.Single(id, "CId");
                Memcache.Store(key, result, DurationCache);
            }
            return(result);
        }
Пример #3
0
        /// <summary>
        /// 根据主键ID取得单一实体,如果没有找到则返回null
        /// </summary>
        /// <param name="id">实体的主键ID</param>
        /// <returns>Bank实体对象</returns>
        public Bank Single(int id)
        {
            var key    = EncodeKey("ID", id);
            var result = Memcache.Get(key) as Bank;

            if (result == null)
            {
                result = base.Single(id, "ID");
                Memcache.Store(key, result, DurationCache);
            }
            return(result);
        }
Пример #4
0
        /// <summary>
        /// 根据主键ID取得单一实体,如果没有找到则返回null
        /// </summary>
        /// <param name="id">实体的主键ID</param>
        /// <returns>Users实体对象</returns>
        public Users Single(int id)
        {
            var key    = EncodeKey("UserId", id);
            var result = Memcache.Get(key) as Users;

            if (result == null)
            {
                result = base.Single(id, "UserId");
                Memcache.Store(key, result, DurationCache);
            }
            return(result);
        }