Exemple #1
0
        /// <summary>
        /// 获取Query获取收藏列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public static PagingDataSet <Favorite> GetFavorites(FavoriteQuery query)
        {
            PagingDataSet <Favorite> favorites = null;
            string cacheKey = CacheKeyManager.GetFavoriteQueryKey(query);

            if (HttpContext.Current != null)
            {
                favorites = HttpContext.Current.Items[cacheKey] as PagingDataSet <Favorite>;
            }
            if (favorites != null)
            {
                return(favorites);
            }

            favorites = HHCache.Instance.Get(cacheKey) as PagingDataSet <Favorite>;
            if (favorites == null)
            {
                int totalRecods;
                favorites = new PagingDataSet <Favorite>();
                List <Favorite> favoriteList = CommonDataProvider.Instance.GetFavorites(query, out totalRecods);
                favorites.Records      = favoriteList;
                favorites.TotalRecords = totalRecods;
                if (HttpContext.Current != null)
                {
                    HttpContext.Current.Items[cacheKey] = favorites;
                }
                HHCache.Instance.Insert(cacheKey, favorites);
            }
            return(favorites);
        }
Exemple #2
0
 /// <summary>
 /// FavoriteQuery获取缓存头信息
 /// </summary>
 /// <param name="userID"></param>
 /// <returns></returns>
 public static string GetFavoritePrefix(FavoriteQuery favoriteQuery)
 {
     if (favoriteQuery.UserID < 0)
     {
         return(FavoriteListPrefix);
     }
     else
     {
         return(UserPrefix + string.Format("Favorites/UseID-{0}/", favoriteQuery.UserID));
     }
 }
Exemple #3
0
 /// <summary>
 /// FavoriteQuery CacheKey
 /// </summary>
 /// <param name="favoriteQuery"></param>
 /// <returns></returns>
 public static string GetFavoriteQueryKey(FavoriteQuery favoriteQuery)
 {
     return(GetFavoritePrefix(favoriteQuery) + string.Format("PI{0}PS{1}UID{2}FTP{3}FT{4}FM{5}",
                                                             favoriteQuery.PageIndex,
                                                             favoriteQuery.PageSize,
                                                             favoriteQuery.UserID,
                                                             favoriteQuery.FavoriteType.HasValue ? (Int32)favoriteQuery.FavoriteType.Value : -1,
                                                             favoriteQuery.FavoriteTitleFilter,
                                                             favoriteQuery.FavoriteMemoFilter
                                                             ));
 }