Ejemplo n.º 1
0
        /// <summary>
        /// 根据FavoriteID获取Favorite信息
        /// </summary>
        /// <param name="favoriteID"></param>
        /// <returns></returns>
        public static Favorite GetFavorite(int favoriteID)
        {
            Favorite favorite = null;
            string   cacheKey = CacheKeyManager.GetFavoriteKey(favoriteID);

            if (HttpContext.Current != null)
            {
                favorite = HttpContext.Current.Items[cacheKey] as Favorite;
            }
            if (favorite != null)
            {
                return(favorite);
            }

            favorite = HHCache.Instance.Get(cacheKey) as Favorite;
            if (favorite == null)
            {
                favorite = CommonDataProvider.Instance.GetFavorite(favoriteID);
                if (HttpContext.Current != null)
                {
                    HttpContext.Current.Items[cacheKey] = favorite;
                }
                HHCache.Instance.Insert(cacheKey, favorite);
            }
            return(favorite);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 将收藏缓存
 /// </summary>
 /// <param name="favorite"></param>
 internal static void AddCachedFavorite(Favorite favorite)
 {
     HHCache.Instance.Insert(CacheKeyManager.GetFavoriteKey(favorite.FavoriteID), favorite);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 清除CacheKey
 /// </summary>
 /// <param name="favorite"></param>
 internal static void RefreshCachedFavorite(Favorite favorite)
 {
     HHCache.Instance.Remove(CacheKeyManager.GetFavoriteKey(favorite.FavoriteID));
     HHCache.Instance.Remove(CacheKeyManager.GetFavoritePrefix(favorite.UserID));
     RefreshCachedFavorite();
 }