public async Task <ActionResult <List <FriendLinkDTO> > > GetFriendLinks()
        {
            var friendLinkDtOs = await _friendLinkService.GetFriendLinksByIsShowAsync(true);

            //读取缓存
            //friendLinkDTOs = await RedisHelper.GetAsync<List<FriendLinkDTO>>("ZswBlog:FriendLink:FriendLinkDTOList");
            //if (friendLinkDTOs == null)
            //{
            // 开启缓存
            //await RedisHelper.SetAsync("ZswBlog:FriendLink:FriendLinkList", friendLinkDTOs, 1200);
            //}
            return(Ok(friendLinkDtOs));
        }
示例#2
0
        public async Task <ActionResult <IEnumerable <FriendLinkDTO> > > GetFriendLinks()
        {
            IEnumerable <FriendLinkDTO> friendLinkDTOs;
            //读取缓存
            List <FriendLinkDTO> friendLinkDTOsR = await RedisHelper.GetAsync <List <FriendLinkDTO> >("ZswBlog:Link:FriendLinkDTOList");

            if (friendLinkDTOsR != null)
            {
                friendLinkDTOs = friendLinkDTOsR;
            }
            else
            {
                //开启缓存
                List <FriendLink> friendLinks = await friendLinkSerivce.GetFriendLinksByIsShowAsync(true);

                friendLinkDTOs = await friendLinkMapper.MapperToDTOsAsync(friendLinks);

                await RedisHelper.SetAsync("ZswBlog:Link:FriendLinkDTOList", friendLinkDTOs, 600);
            }
            return(Ok(friendLinkDTOs));
        }