CacheKeys.PushMsg.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. namespace JiaZhiQuan.Common
  2. {
  3. public static partial class CacheKeys
  4. {
  5. public const int PushMsgThumbsupCacheSecs = 60 * 60 * 24;
  6. /// <summary>
  7. /// 点赞消息推送缓存,对于同一目标点赞,一天只收一次通知
  8. /// </summary>
  9. /// <param name="fromUserId">点赞的用户Id</param>
  10. /// <param name="type">点赞目标类型</param>
  11. /// <param name="targetId">目标编号</param>
  12. /// <returns></returns>
  13. public static string PushMsgThumbsupRepeatability(long fromUserId, ThumbsupTargetType type, long targetId)
  14. {
  15. return GenerateKey($"push_thumbsup:{fromUserId}:{(int)type}:{targetId}");
  16. }
  17. public const int PushMsgThumbsupReceivePerMinCacheSecs = 60;
  18. /// <summary>
  19. /// 同一用户一分钟内只收到1次点赞推送
  20. /// </summary>
  21. public static string PushMsgThumbsupReceivePerMin(long toUserId)
  22. {
  23. return GenerateKey($"push_thumbsup:m1:{toUserId}");
  24. }
  25. public const int PushMsgThumbsupReceivePerHourCacheSecs = 60 * 60;
  26. /// <summary>
  27. /// 同一用户一小时内只收到2次点赞推送
  28. /// </summary>
  29. public static string PushMsgThumbsupReceivePerHour(long toUserId)
  30. {
  31. return GenerateKey($"push_thumbsup:h1:{toUserId}");
  32. }
  33. public const int PushMsgThumbsupReceivePerDayCacheSecs = 24 * 60 * 60;
  34. /// <summary>
  35. /// 同一用户一天内只收到3次点赞推送
  36. /// </summary>
  37. public static string PushMsgThumbsupReceivePerDay(long toUserId)
  38. {
  39. return GenerateKey($"push_thumbsup:d1:{toUserId}");
  40. }
  41. public const int PushMsgFocusUserCacheSecs = 60 * 60 * 24;
  42. /// <summary>
  43. /// 关注消息推送缓存,对于同一目标关注,一天只收一次通知
  44. /// </summary>
  45. public static string PushMsgFocusRepeatability(long fromUserId, long toUserId)
  46. {
  47. return GenerateKey($"push_focus:{fromUserId}:{toUserId}");
  48. }
  49. /// <summary>
  50. /// 用户一个小时内收到的关注通知数量
  51. /// </summary>
  52. public static string PushMsgFocusReceivePerHour(long toUserId)
  53. {
  54. return GenerateKey($"push_focus_count:h1:{toUserId}");
  55. }
  56. /// <summary>
  57. /// 用户一天内收到的关注通知数量
  58. /// </summary>
  59. public static string PushMsgFocusReceivePerDay(long toUserId)
  60. {
  61. return GenerateKey($"push_focus_count:d1:{toUserId}");
  62. }
  63. public const int PushMsgCommentPerDayCacheSecs = 60 * 60 * 24;
  64. /// <summary>
  65. /// 同一ID对另一ID用户,一天最多3次评论,除非楼主回复了后,再进行提醒(清除逻辑放在了评论通知中)
  66. /// </summary>
  67. public static string PushMsgCommentPertDay(long fromUserId, long toUserId)
  68. {
  69. return GenerateKey($"push_comment:d1:{fromUserId}:{toUserId}");
  70. }
  71. public const int PushMsgCommentReceivePerHourCacheSecs = 60 * 60 * 24;
  72. /// <summary>
  73. /// 用户一个小时内收到的评论通知数量
  74. /// </summary>
  75. public static string PushMsgCommentReceivePerHour(long toUserId)
  76. {
  77. return GenerateKey($"push_comment_count:h1:{toUserId}");
  78. }
  79. public const int PushMsgCommentReceivePerDayCacheSecs = 24 * 60 * 60;
  80. /// <summary>
  81. /// 用户一天内收到的评论通知数量
  82. /// </summary>
  83. public static string PushMsgCommentReceivePerDay(long toUserId)
  84. {
  85. return GenerateKey($"push_comment_count:d1:{toUserId}");
  86. }
  87. public const int PushMsgUserConfigCacheSecs = 60 * 30;
  88. /// <summary>
  89. /// 推送用户配置
  90. /// </summary>
  91. public static string PushMsgUserConfig(long userId)
  92. {
  93. return GenerateKey($"push_userconfig:{userId}");
  94. }
  95. }
  96. }