TopicCache.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using CB.Cache;
  6. using CB.Entity;
  7. namespace CB.Data
  8. {
  9. public partial class Caches
  10. {
  11. /// <summary>
  12. /// 走势图表帮助文章列表(限走势图表使用)
  13. /// </summary>
  14. /// <param name="cid">文章分类ID</param>
  15. /// <returns></returns>
  16. public static IList<TopicInfo> GetHelpList(int cid)
  17. {
  18. var key = CacheKeys.TopicList + "-" + cid.ToString();
  19. var cache = CBCache.GetCacheService();
  20. IList<TopicInfo> list = cache.GetObject(key) as IList<TopicInfo>;
  21. if (null == list)
  22. {
  23. list = TopicService.ToList(new TopicInfo() { Cid = cid });
  24. cache.AddObject(key, list);
  25. }
  26. return list;
  27. }
  28. /// <summary>
  29. /// 走势图表帮助文章列表(限走势图表使用)
  30. /// </summary>
  31. /// <param name="cid">文章分类ID</param>
  32. /// <param name="topSize">记录条数</param>
  33. /// <returns></returns>
  34. public static IList<TopicInfo> GetHelpList(int cid, int topSize)
  35. {
  36. var list = GetHelpList(cid);
  37. if (null == list || 0 >= list.Count)
  38. return null;
  39. IList<TopicInfo> r = new List<TopicInfo>();
  40. int count = list.Count;
  41. count = topSize >= count ? count : topSize;
  42. for (int i = 0; i < count; i++)
  43. {
  44. r.Add(list[i]);
  45. }
  46. return r;
  47. }
  48. }
  49. }