コード例 #1
0
        /// <summary>
        /// 1:默认从只读的缓存服务器获取数据
        /// 2:若读取不到,就会到接口上获取,接口会把数据缓存到只读服务器上,为下次阅读提高性能
        /// </summary>
        /// <param name="userInfo"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public static BaseUserEntity GetObjectByCache(BaseUserInfo userInfo, string id)
        {
            BaseUserEntity result = null;

            string key = "User:" + id;

            result = BaseUserManager.GetCacheByKey(key);

            // 远程通过接口获取数据
            if (result == null)
            {
                result = GetObject(userInfo, id);
            }

            return(result);
        }