{"id":67552,"date":"2026-01-28T22:32:56","date_gmt":"2026-01-28T14:32:56","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/67552.html"},"modified":"2026-01-28T22:32:56","modified_gmt":"2026-01-28T14:32:56","slug":"%e5%a4%a9%e6%9c%ba%e5%ad%a6%e5%a0%82-%e7%82%b9%e8%b5%9e%e5%8a%9f%e8%83%bd","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/67552.html","title":{"rendered":"\u5929\u673a\u5b66\u5802\u2014\u2014\u70b9\u8d5e\u529f\u80fd"},"content":{"rendered":"<p id=\"main-toc\">\u76ee\u5f55<\/p>\n<p id=\"1.%E5%8E%9F%E5%A7%8B%E7%9A%84%E7%82%B9%E8%B5%9E%E4%B8%9A%E5%8A%A1-toc\" style=\"margin-left:0px\">1.\u539f\u59cb\u7684\u70b9\u8d5e\u4e1a\u52a1<\/p>\n<p id=\"1.1%E9%A1%B5%E9%9D%A2%E5%8E%9F%E5%9E%8B-toc\" style=\"margin-left:40px\">1.1\u9875\u9762\u539f\u578b<\/p>\n<p id=\"1.2%E7%82%B9%E8%B5%9E%E4%B8%9A%E5%8A%A1-toc\" style=\"margin-left:40px\">1.2\u70b9\u8d5e\u4e1a\u52a1<\/p>\n<p id=\"1.2.1%E6%95%B0%E6%8D%AE%E5%BA%93%E8%A1%A8-toc\" style=\"margin-left:80px\">1.2.1\u6570\u636e\u5e93\u8868<\/p>\n<p id=\"1.2.2%E4%B8%9A%E5%8A%A1%E6%B5%81%E7%A8%8B-toc\" style=\"margin-left:80px\">1.2.2\u4e1a\u52a1\u6d41\u7a0b<\/p>\n<p id=\"1.2.3%E4%B8%9A%E5%8A%A1%E4%BB%A3%E7%A0%81-toc\" style=\"margin-left:80px\">1.2.3\u4e1a\u52a1\u4ee3\u7801<\/p>\n<p id=\"1.3%20%E5%8E%9F%E5%A7%8B%E6%96%B9%E6%A1%88%E7%9A%84%E6%80%A7%E8%83%BD%E7%93%B6%E9%A2%88-toc\" style=\"margin-left:40px\">1.3 \u539f\u59cb\u65b9\u6848\u7684\u6027\u80fd\u74f6\u9888<\/p>\n<p id=\"2.%E9%AB%98%E5%B9%B6%E5%8F%91%E4%BC%98%E5%8C%96%E6%80%9D%E8%B7%AF%EF%BC%9ARedis%20%2B%20%E5%90%88%E5%B9%B6%E5%86%99%E8%AF%B7%E6%B1%82-toc\" style=\"margin-left:0px\">2.\u9ad8\u5e76\u53d1\u4f18\u5316\u601d\u8def&#xff1a;Redis &#043; \u5408\u5e76\u5199\u8bf7\u6c42<\/p>\n<p id=\"2.1%20%E4%BC%98%E5%8C%96%E6%96%B9%E5%90%91%E5%88%86%E6%9E%90-toc\" style=\"margin-left:40px\">2.1 \u4f18\u5316\u65b9\u5411\u5206\u6790<\/p>\n<p id=\"2.2%E4%BF%AE%E6%94%B9%E4%B9%8B%E5%90%8E%E7%9A%84%E4%B8%9A%E5%8A%A1%E5%88%86%E6%9E%90-toc\" style=\"margin-left:40px\">2.2\u4fee\u6539\u4e4b\u540e\u7684\u4e1a\u52a1\u5206\u6790<\/p>\n<p id=\"2.2.1%E6%A0%B8%E5%BF%83%E4%B8%9A%E5%8A%A1%E6%B5%81%E7%A8%8B-toc\" style=\"margin-left:80px\">2.2.1\u6838\u5fc3\u4e1a\u52a1\u6d41\u7a0b<\/p>\n<p id=\"2.2.2Redis%20%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E9%80%89%E5%9E%8B-toc\" style=\"margin-left:80px\">2.2.2Redis \u6570\u636e\u7ed3\u6784\u9009\u578b<\/p>\n<p id=\"2.3%E4%BB%A3%E7%A0%81%E5%AE%9E%E7%8E%B0-toc\" style=\"margin-left:40px\">2.3\u4ee3\u7801\u5b9e\u73b0<\/p>\n<p id=\"2.3.1%E4%BB%A3%E7%A0%81%E5%AE%9E%E7%8E%B0%E6%B5%81%E7%A8%8B%E5%9B%BE-toc\" style=\"margin-left:80px\">2.3.1\u4ee3\u7801\u5b9e\u73b0\u6d41\u7a0b\u56fe<\/p>\n<p id=\"2.3.2%E6%A0%B8%E5%BF%83%E6%8E%A5%E5%8F%A3%E6%94%B9%E9%80%A0%EF%BC%88%E7%82%B9%E8%B5%9E%20%2F%20%E5%8F%96%E6%B6%88%EF%BC%89-toc\" style=\"margin-left:80px\">2.3.2\u6838\u5fc3\u63a5\u53e3\u6539\u9020&#xff08;\u70b9\u8d5e \/ \u53d6\u6d88&#xff09;<\/p>\n<p id=\"2.3.3Pipeline%20%E4%BC%98%E5%8C%96%E6%89%B9%E9%87%8F%E6%9F%A5%E8%AF%A2%E6%80%A7%E8%83%BD-toc\" style=\"margin-left:80px\">2.3.3Pipeline \u4f18\u5316\u6279\u91cf\u67e5\u8be2\u6027\u80fd<\/p>\n<p id=\"2.3.4%20%E5%AE%9A%E6%97%B6%E4%BB%BB%E5%8A%A1%E6%89%B9%E9%87%8F%E5%90%8C%E6%AD%A5%E7%82%B9%E8%B5%9E%E6%95%B0-toc\" style=\"margin-left:80px\">2.3.4 \u5b9a\u65f6\u4efb\u52a1\u6279\u91cf\u540c\u6b65\u70b9\u8d5e\u6570<\/p>\n<p id=\"3.%E8%BF%9B%E4%B8%80%E6%AD%A5%E4%BC%98%E5%8C%96%EF%BC%9A%E5%AE%9A%E6%9C%9F%E6%8C%81%E4%B9%85%E5%8C%96%E5%88%B0%E6%95%B0%E6%8D%AE%E5%BA%93%EF%BC%8C%E9%87%87%E7%94%A8LRU%E7%A7%BB%E9%99%A4%E6%9C%80%E8%BF%91%E6%9C%80%E5%B0%91%E8%AE%BF%E9%97%AE-toc\" style=\"margin-left:0px\">3.\u8fdb\u4e00\u6b65\u4f18\u5316&#xff1a;\u5b9a\u671f\u6301\u4e45\u5316\u5230\u6570\u636e\u5e93&#xff0c;\u91c7\u7528LRU\u79fb\u9664\u6700\u8fd1\u6700\u5c11\u8bbf\u95ee<\/p>\n<p id=\"3.1%E5%AE%9A%E4%B9%89%E6%96%B0%E7%9A%84Redis%E7%BB%93%E6%9E%84%E7%94%A8%E4%BA%8E%E5%AE%9E%E7%8E%B0LRU%E5%92%8C%E6%8C%81%E4%B9%85%E5%8C%96-toc\" style=\"margin-left:40px\">3.1\u5b9a\u4e49\u65b0\u7684Redis\u7ed3\u6784\u7528\u4e8e\u5b9e\u73b0LRU\u548c\u6301\u4e45\u5316<\/p>\n<p id=\"3.1.1LRU%20%E8%AE%BF%E9%97%AE%E7%AD%96%E7%95%A5%E8%A1%A8-toc\" style=\"margin-left:80px\">3.1.1LRU \u8bbf\u95ee\u7b56\u7565\u8868<\/p>\n<p id=\"3.1.2%E4%B8%9A%E5%8A%A1%E7%B1%BB%E5%9E%8B%E6%98%A0%E5%B0%84%E8%A1%A8%20(Hash)-toc\" style=\"margin-left:80px\">3.1.2\u4e1a\u52a1\u7c7b\u578b\u6620\u5c04\u8868 (Hash)<\/p>\n<p id=\"3.2%E4%B8%9A%E5%8A%A1%E6%B5%81%E7%A8%8B-toc\" style=\"margin-left:40px\">3.2\u4e1a\u52a1\u6d41\u7a0b<\/p>\n<p id=\"3.2.1%E5%AE%9E%E6%97%B6%E4%BA%A4%E4%BA%92%E6%B5%81%E7%A8%8B-toc\" style=\"margin-left:80px\">3.2.1\u5b9e\u65f6\u4ea4\u4e92\u6d41\u7a0b<\/p>\n<p id=\"3.2.2%E5%BC%82%E6%AD%A5%E6%8C%81%E4%B9%85%E5%8C%96%E6%B5%81%E7%A8%8B-toc\" style=\"margin-left:80px\">3.2.2\u5f02\u6b65\u6301\u4e45\u5316\u6d41\u7a0b<\/p>\n<p id=\"3.3%E4%BB%A3%E7%A0%81%E5%AE%9E%E7%8E%B0-toc\" style=\"margin-left:40px\">3.3\u4ee3\u7801\u5b9e\u73b0<\/p>\n<hr id=\"hr-toc\" \/>\n<p>\u672c\u6587\u4e3b\u8981\u662f\u6211\u4e2a\u4eba\u5b66\u4e60\u5929\u673a\u5b66\u5802\u8fd9\u4e2a\u9879\u76ee\u81ea\u5df1\u7684\u4e00\u4e9b\u7406\u89e3\u548c\u4f18\u5316\u90e8\u5206&#xff0c;\u4e3b\u8981\u662f\u6458\u51fa\u9879\u76ee\u4e2d\u4e00\u4e9b\u6bd4\u8f83\u901a\u7528\u7684\u90e8\u5206&#xff0c;\u65b9\u4fbf\u5927\u5bb6\u4ee5\u53ca\u81ea\u5df1\u4e4b\u540e\u5982\u679c\u9047\u5230\u4e86\u7c7b\u4f3c\u7684\u4e1a\u52a1\u53ef\u4ee5\u8fdb\u884c\u53c2\u8003\u4f7f\u7528<\/p>\n<h2 id=\"1.%E5%8E%9F%E5%A7%8B%E7%9A%84%E7%82%B9%E8%B5%9E%E4%B8%9A%E5%8A%A1\">1.\u539f\u59cb\u7684\u70b9\u8d5e\u4e1a\u52a1<\/h2>\n<h3 id=\"1.1%E9%A1%B5%E9%9D%A2%E5%8E%9F%E5%9E%8B\">1.1\u9875\u9762\u539f\u578b<\/h3>\n<p>\u5f53\u7528\u6237\u70b9\u51fb\u70b9\u8d5e\u6309\u94ae\u7684\u65f6\u5019&#xff0c;\u7b2c\u4e00\u6b21\u70b9\u51fb\u662f\u70b9\u8d5e&#xff0c;\u6309\u94ae\u4f1a\u9ad8\u4eae&#xff1b;\u7b2c\u4e8c\u6b21\u70b9\u51fb\u662f\u53d6\u6d88&#xff0c;\u70b9\u8d5e\u6309\u94ae\u53d8\u7070&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"508\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260128143253-697a1e153a338.png\" width=\"840\" \/><\/p>\n<h3 id=\"1.2%E7%82%B9%E8%B5%9E%E4%B8%9A%E5%8A%A1\">1.2\u70b9\u8d5e\u4e1a\u52a1<\/h3>\n<h4 id=\"1.2.1%E6%95%B0%E6%8D%AE%E5%BA%93%E8%A1%A8\">1.2.1\u6570\u636e\u5e93\u8868<\/h4>\n<p>\u8868\u53ea\u6709\u4e00\u5f20&#xff0c;\u5f88\u7b80\u5355&#xff0c;\u5c31\u662f\u8c01\u7ed9\u54ea\u4e2a\u4e1a\u52a1\u70b9\u4e86\u8d5e\u7684\u4e00\u4e2a\u8bb0\u5f55&#xff1b;\u70b9\u8d5e\u6570\u5c31\u662f\u7edf\u8ba1\u8fd9\u6761\u6570\u636e\u6709\u591a\u5c11\u4eba\u70b9\u8d5e\u4e86\u3002liked_record \u7528\u4e8e\u8bb0\u5f55\u70b9\u8d5e\u884c\u4e3a&#xff0c;\u901a\u8fc7 biz_type \u533a\u5206\u4e0d\u540c\u4e1a\u52a1\u3001biz_id \u5173\u8054\u5177\u4f53\u4e1a\u52a1 ID&#xff0c;\u7ed3\u5408\u7528\u6237 ID \u505a\u552f\u4e00\u7d22\u5f15\u9632\u6b62\u91cd\u590d\u70b9\u8d5e&#xff1a;<\/p>\n<p>CREATE TABLE IF NOT EXISTS &#096;liked_record&#096; (<br \/>\n  &#096;id&#096; bigint NOT NULL AUTO_INCREMENT COMMENT &#039;\u4e3b\u952eid&#039;,<br \/>\n  &#096;user_id&#096; bigint NOT NULL COMMENT &#039;\u7528\u6237id&#039;,<br \/>\n  &#096;biz_id&#096; bigint NOT NULL COMMENT &#039;\u70b9\u8d5e\u7684\u4e1a\u52a1id&#039;,<br \/>\n  &#096;biz_type&#096; VARCHAR(16) NOT NULL COMMENT &#039;\u70b9\u8d5e\u7684\u4e1a\u52a1\u7c7b\u578b&#039;,<br \/>\n  &#096;create_time&#096; datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT &#039;\u521b\u5efa\u65f6\u95f4&#039;,<br \/>\n  &#096;update_time&#096; datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT &#039;\u66f4\u65b0\u65f6\u95f4&#039;,<br \/>\n  PRIMARY KEY (&#096;id&#096;),<br \/>\n  UNIQUE KEY &#096;idx_biz_user&#096; (&#096;biz_id&#096;,&#096;user_id&#096;)<br \/>\n) ENGINE&#061;InnoDB DEFAULT CHARSET&#061;utf8mb4 COMMENT&#061;&#039;\u70b9\u8d5e\u8bb0\u5f55\u8868&#039;; <\/p>\n<p>\u4e1a\u52a1\u65b9&#xff08;\u5982\u4e92\u52a8\u95ee\u7b54&#xff09;\u5219\u5728\u81ea\u8eab\u8868\u4e2d\u7ef4\u62a4 liked_times \u5b57\u6bb5&#xff0c;\u8bb0\u5f55\u70b9\u8d5e\u603b\u6570\u3002<\/p>\n<h4 id=\"1.2.2%E4%B8%9A%E5%8A%A1%E6%B5%81%E7%A8%8B\">1.2.2\u4e1a\u52a1\u6d41\u7a0b<\/h4>\n<ul>\n<li>\n<p>\u70b9\u8d5e\u5c31\u65b0\u589e\u4e00\u6761\u70b9\u8d5e\u8bb0\u5f55&#xff0c;\u53d6\u6d88\u70b9\u8d5e\u5c31\u5220\u9664\u8bb0\u5f55<\/p>\n<\/li>\n<li>\n<p>\u7528\u6237\u4e0d\u80fd\u91cd\u590d\u70b9\u8d5e<\/p>\n<\/li>\n<li>\n<p>\u70b9\u8d5e\u6570\u7531\u5177\u4f53\u7684\u4e1a\u52a1\u65b9\u4fdd\u5b58&#xff0c;\u9700\u8981\u901a\u77e5\u4e1a\u52a1\u65b9\u66f4\u65b0\u70b9\u8d5e\u6570<\/p>\n<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"544\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260128143253-697a1e156d713.png\" width=\"1320\" \/><\/p>\n<p>\u9700\u8981\u6ce8\u610f\u7684\u662f&#xff0c;\u7531\u4e8e\u6bcf\u6b21\u70b9\u8d5e\u7684\u4e1a\u52a1\u7c7b\u578b\u4e0d\u540c&#xff0c;\u6240\u4ee5\u6ca1\u6709\u5fc5\u8981\u901a\u77e5\u5230\u6240\u6709\u4e1a\u52a1\u65b9&#xff0c;\u800c\u662f\u4ec5\u4ec5\u901a\u77e5\u4e0e\u5f53\u524d\u70b9\u8d5e\u4e1a\u52a1\u5173\u8054\u7684\u4e1a\u52a1\u65b9\u5373\u53ef\u3002<\/p>\n<p>\u5728RabbitMQ\u4e2d&#xff0c;\u5229\u7528TOPIC\u7c7b\u578b\u7684\u4ea4\u6362\u673a&#xff0c;\u7ed3\u5408\u4e0d\u540c\u7684RoutingKey&#xff0c;\u53ef\u4ee5\u5b9e\u73b0\u901a\u77e5\u5bf9\u8c61\u7684\u53d8\u5316\u3002\u6211\u4eec\u9700\u8981\u8ba9\u4e0d\u540c\u7684\u4e1a\u52a1\u65b9\u76d1\u542c\u4e0d\u540c\u7684RoutingKey&#xff0c;\u7136\u540e\u53d1\u9001\u901a\u77e5\u65f6\u6839\u636e\u70b9\u8d5e\u7c7b\u578b\u4e0d\u540c&#xff0c;\u53d1\u9001\u4e0d\u540cRoutingKey&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"350\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260128143253-697a1e15abc7a.png\" width=\"1021\" \/><\/p>\n<h4 id=\"1.2.3%E4%B8%9A%E5%8A%A1%E4%BB%A3%E7%A0%81\">1.2.3\u4e1a\u52a1\u4ee3\u7801<\/h4>\n<p>\u2460\u70b9\u8d5e\u76f8\u5173\u4ee3\u7801<\/p>\n<p>MQ\u5e38\u91cf<\/p>\n<p>package com.tianji.common.constants;<\/p>\n<p>public interface MqConstants {<br \/>\n    interface Exchange{<br \/>\n         \/*\u70b9\u8d5e\u8bb0\u5f55\u6709\u5173\u7684\u4ea4\u6362\u673a*\/<br \/>\n        String LIKE_RECORD_EXCHANGE &#061; &#034;like.record.topic&#034;;<br \/>\n    }<br \/>\n    interface Queue {<br \/>\n        String ERROR_QUEUE_TEMPLATE &#061; &#034;error.{}.queue&#034;;<br \/>\n    }<br \/>\n    interface Key{<br \/>\n        \/*\u70b9\u8d5e\u7684RoutingKey*\/<br \/>\n        String LIKED_TIMES_KEY_TEMPLATE &#061; &#034;{}.times.changed&#034;;<br \/>\n        \/*\u95ee\u7b54*\/<br \/>\n        String QA_LIKED_TIMES_KEY &#061; &#034;QA.times.changed&#034;;<br \/>\n        \/*\u7b14\u8bb0*\/<br \/>\n        String NOTE_LIKED_TIMES_KEY &#061; &#034;NOTE.times.changed&#034;;<\/p>\n<p>    }<br \/>\n}<\/p>\n<p>DTO<\/p>\n<p>&#064;Data<br \/>\n&#064;NoArgsConstructor<br \/>\n&#064;AllArgsConstructor<br \/>\npublic class LikedTimesDTO {<br \/>\n    \/**<br \/>\n     * \u70b9\u8d5e\u7684\u4e1a\u52a1id<br \/>\n     *\/<br \/>\n    private Long bizId;<br \/>\n    \/**<br \/>\n     * \u603b\u7684\u70b9\u8d5e\u6b21\u6570<br \/>\n     *\/<br \/>\n    private Integer likedTimes;<br \/>\n} <\/p>\n<p>service\u5b8c\u6574\u4e1a\u52a1\u4ee3\u7801<\/p>\n<p>package com.tianji.remark.service.impl;<\/p>\n<p>import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;<br \/>\nimport com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;<br \/>\nimport com.tianji.common.autoconfigure.mq.RabbitMqHelper;<br \/>\nimport com.tianji.common.utils.StringUtils;<br \/>\nimport com.tianji.common.utils.UserContext;<br \/>\nimport com.tianji.remark.domain.dto.LikeRecordFormDTO;<br \/>\nimport com.tianji.remark.domain.po.LikedRecord;<br \/>\nimport com.tianji.remark.mapper.LikedRecordMapper;<br \/>\nimport com.tianji.remark.service.ILikedRecordService;<br \/>\nimport lombok.RequiredArgsConstructor;<\/p>\n<p>import java.util.List;<br \/>\nimport java.util.Set;<br \/>\nimport java.util.stream.Collectors;<\/p>\n<p>import static com.tianji.common.constants.MqConstants.Exchange.LIKE_RECORD_EXCHANGE;<br \/>\nimport static com.tianji.common.constants.MqConstants.Key.LIKED_TIMES_KEY_TEMPLATE;<\/p>\n<p>\/**<br \/>\n * &lt;p&gt;<br \/>\n * \u70b9\u8d5e\u8bb0\u5f55\u8868 \u670d\u52a1\u5b9e\u73b0\u7c7b<br \/>\n * &lt;\/p&gt;<br \/>\n *\/<br \/>\n&#064;Service<br \/>\n&#064;RequiredArgsConstructor<br \/>\npublic class LikedRecordServiceImpl extends ServiceImpl&lt;LikedRecordMapper, LikedRecord&gt; implements ILikedRecordService {<\/p>\n<p>    private final RabbitMqHelper mqHelper;<\/p>\n<p>    &#064;Override<br \/>\n    public void addLikeRecord(LikeRecordFormDTO recordDTO) {<br \/>\n        \/\/ 1.\u57fa\u4e8e\u524d\u7aef\u7684\u53c2\u6570&#xff0c;\u5224\u65ad\u662f\u6267\u884c\u70b9\u8d5e\u8fd8\u662f\u53d6\u6d88\u70b9\u8d5e<br \/>\n        boolean success &#061; recordDTO.getLiked() ? like(recordDTO) : unlike(recordDTO);<br \/>\n        \/\/ 2.\u5224\u65ad\u662f\u5426\u6267\u884c\u6210\u529f&#xff0c;\u5982\u679c\u5931\u8d25&#xff0c;\u5219\u76f4\u63a5\u7ed3\u675f<br \/>\n        if (!success) {<br \/>\n            return;<br \/>\n        }<br \/>\n        \/\/ 3.\u5982\u679c\u6267\u884c\u6210\u529f&#xff0c;\u7edf\u8ba1\u70b9\u8d5e\u603b\u6570<br \/>\n        Integer likedTimes &#061; lambdaQuery()<br \/>\n                .eq(LikedRecord::getBizId, recordDTO.getBizId())<br \/>\n                .count();<br \/>\n        \/\/ 4.\u53d1\u9001MQ\u901a\u77e5<br \/>\n        mqHelper.send(<br \/>\n                LIKE_RECORD_EXCHANGE,<br \/>\n                StringUtils.format(LIKED_TIMES_KEY_TEMPLATE, recordDTO.getBizType()),<br \/>\n                LikedTimesDTO.of(recordDTO.getBizId(), likedTimes));<br \/>\n    }<\/p>\n<p>    private boolean unlike(LikeRecordFormDTO recordDTO) {<br \/>\n        return remove(new QueryWrapper&lt;LikedRecord&gt;().lambda()<br \/>\n                .eq(LikedRecord::getUserId, UserContext.getUser())<br \/>\n                .eq(LikedRecord::getBizId, recordDTO.getBizId()));<br \/>\n    }<\/p>\n<p>    private boolean like(LikeRecordFormDTO recordDTO) {<br \/>\n        Long userId &#061; UserContext.getUser();<br \/>\n        \/\/ 1.\u67e5\u8be2\u70b9\u8d5e\u8bb0\u5f55<br \/>\n        Integer count &#061; lambdaQuery()<br \/>\n                .eq(LikedRecord::getUserId, userId)<br \/>\n                .eq(LikedRecord::getBizId, recordDTO.getBizId())<br \/>\n                .count();<br \/>\n        \/\/ 2.\u5224\u65ad\u662f\u5426\u5b58\u5728&#xff0c;\u5982\u679c\u5df2\u7ecf\u5b58\u5728&#xff0c;\u76f4\u63a5\u7ed3\u675f<br \/>\n        if (count &gt; 0) {<br \/>\n            return false;<br \/>\n        }<br \/>\n        \/\/ 3.\u5982\u679c\u4e0d\u5b58\u5728&#xff0c;\u76f4\u63a5\u65b0\u589e<br \/>\n        LikedRecord r &#061; new LikedRecord();<br \/>\n        r.setUserId(userId);<br \/>\n        r.setBizId(recordDTO.getBizId());<br \/>\n        r.setBizType(recordDTO.getBizType());<br \/>\n        save(r);<br \/>\n        return true;<br \/>\n    }<br \/>\n} <\/p>\n<p>\u2461\u6279\u91cf\u67e5\u8be2\u70b9\u8d5e\u72b6\u6001&#xff08;\u5176\u5b9e\u5c31\u76f8\u5f53\u4e8e\u67e5\u8be2\u7528\u6237\u4e3a\u54ea\u4e9b\u6d88\u606f\u8fdb\u884c\u4e86\u70b9\u8d5e&#xff09;&#xff0c;\u4f9b\u4e1a\u52a1\u65b9\u67e5\u8be2\u5f53\u524d\u7528\u6237\u5bf9\u6307\u5b9a\u4e1a\u52a1\u7684\u70b9\u8d5e\u72b6\u6001&#xff0c;\u8fd4\u56de\u70b9\u8d5e\u8fc7\u7684\u4e1a\u52a1 ID \u96c6\u5408\u3002<\/p>\n<p>\u4e1a\u52a1\u4ee3\u7801&#xff1a;<\/p>\n<p>\/**<br \/>\n     * \u5224\u65ad\u4e1a\u52a1\u662f\u5426\u88ab\u8be5\u7528\u6237\u70b9\u8d5e<br \/>\n     *<br \/>\n     * &#064;param bizIds \u4e1a\u52a1id\u5217\u8868<br \/>\n     * &#064;return \u4e1a\u52a1\u662f\u5426\u88ab\u70b9\u8d5e<br \/>\n     *\/<br \/>\n    &#064;Override<br \/>\n    public Set&lt;Long&gt; isBizLiked(List&lt;Long&gt; bizIds) {<br \/>\n        \/\/ 1.\u83b7\u53d6\u767b\u5f55\u7528\u6237id<br \/>\n        Long userId &#061; UserContext.getUser();<br \/>\n        \/\/ 2.\u67e5\u8be2\u70b9\u8d5e\u72b6\u6001<br \/>\n        List&lt;LikedRecord&gt; list &#061; lambdaQuery()<br \/>\n                .in(LikedRecord::getBizId, bizIds)<br \/>\n                .eq(LikedRecord::getUserId, userId)<br \/>\n                .list();<br \/>\n        \/\/ 3.\u8fd4\u56de\u7ed3\u679c<br \/>\n        return list.stream().map(LikedRecord::getBizId).collect(Collectors.toSet());<br \/>\n    } <\/p>\n<h3 id=\"1.3%20%E5%8E%9F%E5%A7%8B%E6%96%B9%E6%A1%88%E7%9A%84%E6%80%A7%E8%83%BD%E7%93%B6%E9%A2%88\">1.3 \u539f\u59cb\u65b9\u6848\u7684\u6027\u80fd\u74f6\u9888<\/h3>\n<p>\u539f\u59cb\u65b9\u6848\u80fd\u6ee1\u8db3\u529f\u80fd\u9700\u6c42&#xff0c;\u4f46\u5728\u9ad8\u5e76\u53d1\u573a\u666f\u4e0b\u66b4\u9732\u51fa\u81f4\u547d\u95ee\u9898&#xff1a;<\/p>\n<ul>\n<li>\u6570\u636e\u5e93\u538b\u529b\u8fc7\u5927&#xff1a;\u6bcf\u4e00\u6b21\u70b9\u8d5e \/ \u53d6\u6d88\u64cd\u4f5c\u90fd\u6d89\u53ca\u6570\u636e\u5e93\u7684 insert\/delete &#043; count&#xff0c;\u9ad8\u9891\u64cd\u4f5c\u4f1a\u8017\u5c3d\u6570\u636e\u5e93\u8fde\u63a5\u6c60&#xff0c;\u54cd\u5e94\u5ef6\u8fdf\u98d9\u5347&#xff1b;<\/li>\n<li>\u65e0\u6548\u5199\u64cd\u4f5c\u591a&#xff1a;\u7528\u6237\u53cd\u590d\u70b9\u8d5e\u3001\u53d6\u6d88\u70b9\u8d5e\u65f6&#xff0c;\u6570\u636e\u5e93\u4f1a\u6267\u884c\u591a\u6b21\u65e0\u6548\u5199&#xff0c;\u4e14\u6bcf\u6b21\u90fd\u8981\u53d1\u9001 MQ \u901a\u77e5&#xff0c;\u6d6a\u8d39\u8d44\u6e90&#xff1b;<\/li>\n<li>\u7f51\u7edc\u4ea4\u4e92\u6210\u672c\u9ad8&#xff1a;\u6279\u91cf\u67e5\u8be2\u70b9\u8d5e\u72b6\u6001\u65f6&#xff0c;\u9700\u591a\u6b21\u67e5\u8be2\u6570\u636e\u5e93&#xff0c;\u7f51\u7edc\u5f80\u8fd4\u6b21\u6570\u591a&#xff0c;\u6027\u80fd\u4f4e\u4e0b\u3002<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"393\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260128143253-697a1e15cca62.png\" width=\"1280\" \/><\/p>\n<\/p>\n<h2 id=\"2.%E9%AB%98%E5%B9%B6%E5%8F%91%E4%BC%98%E5%8C%96%E6%80%9D%E8%B7%AF%EF%BC%9ARedis%20%2B%20%E5%90%88%E5%B9%B6%E5%86%99%E8%AF%B7%E6%B1%82\">2.\u9ad8\u5e76\u53d1\u4f18\u5316\u601d\u8def&#xff1a;Redis &#043; \u5408\u5e76\u5199\u8bf7\u6c42<\/h2>\n<h3 id=\"2.1%20%E4%BC%98%E5%8C%96%E6%96%B9%E5%90%91%E5%88%86%E6%9E%90\">2.1 \u4f18\u5316\u65b9\u5411\u5206\u6790<\/h3>\n<p>\u9488\u5bf9\u9ad8\u5e76\u53d1\u5199\u573a\u666f&#xff0c;\u5e38\u89c1\u4f18\u5316\u624b\u6bb5\u6709\u4e09\u79cd&#xff1a;<\/p>\n<li>\u4f18\u5316 SQL \/ \u4ee3\u7801&#xff1a;\u57fa\u7840\u64cd\u4f5c&#xff0c;\u5bf9\u9ad8\u9891\u5199\u573a\u666f\u63d0\u5347\u6709\u9650&#xff1b;<\/li>\n<li>\u540c\u6b65\u6539\u5f02\u6b65&#xff1a;\u901a\u8fc7 MQ \u964d\u4f4e\u54cd\u5e94\u65f6\u95f4&#xff0c;\u4f46\u672a\u51cf\u5c11\u603b\u5199\u5e93\u6b21\u6570&#xff1b;<\/li>\n<li>\u5408\u5e76\u5199\u8bf7\u6c42&#xff1a;\u5c06\u9ad8\u9891\u5199\u64cd\u4f5c\u7f13\u5b58\u5230 Redis&#xff0c;\u79ef\u7d2f\u5230\u4e00\u5b9a\u91cf\u540e\u6279\u91cf\u5199\u5165\u6570\u636e\u5e93&#xff0c;\u4ece\u6839\u6e90\u51cf\u5c11\u5199\u5e93\u6b21\u6570\u3002<\/li>\n<p>\u70b9\u8d5e\u4e1a\u52a1\u7684\u6838\u5fc3\u7279\u6027\u662f<span style=\"color:#fe2c24\">\u300c\u6700\u7ec8\u7ed3\u679c\u6709\u6548&#xff0c;\u4e2d\u95f4\u8fc7\u7a0b\u53ef\u5ffd\u7565\u300d<\/span>\u2014\u2014 \u7528\u6237\u53cd\u590d\u70b9\u8d5e \/ \u53d6\u6d88&#xff0c;\u6700\u7ec8\u53ea\u9700\u8981\u4fdd\u7559\u300c\u662f\u5426\u70b9\u8d5e\u300d\u548c\u300c\u6700\u7ec8\u70b9\u8d5e\u6570\u300d&#xff0c;\u5b8c\u5168\u9002\u914d\u300c\u5408\u5e76\u5199\u8bf7\u6c42\u300d\u65b9\u6848\u3002\u56e0\u6b64\u6211\u4eec\u9009\u62e9<span style=\"color:#fe2c24\">\u300cRedis \u7f13\u5b58 &#043; \u5b9a\u65f6\u6279\u91cf\u540c\u6b65\u300d<\/span>\u7684\u4f18\u5316\u8def\u5f84&#xff0c;\u517c\u987e\u9ad8\u6027\u80fd\u4e0e\u6570\u636e\u4e00\u81f4\u6027\u3002<\/p>\n<\/p>\n<h3 id=\"2.2%E4%BF%AE%E6%94%B9%E4%B9%8B%E5%90%8E%E7%9A%84%E4%B8%9A%E5%8A%A1%E5%88%86%E6%9E%90\">2.2\u4fee\u6539\u4e4b\u540e\u7684\u4e1a\u52a1\u5206\u6790<\/h3>\n<h4 id=\"2.2.1%E6%A0%B8%E5%BF%83%E4%B8%9A%E5%8A%A1%E6%B5%81%E7%A8%8B\">2.2.1\u6838\u5fc3\u4e1a\u52a1\u6d41\u7a0b<\/h4>\n<p>\u4f18\u5316\u540e\u7684\u70b9\u8d5e\u6d41\u7a0b\u6838\u5fc3\u662f\u300c\u5148\u5199\u7f13\u5b58&#xff0c;\u540e\u6279\u91cf\u540c\u6b65\u300d&#xff1a;<\/p>\n<ul>\n<li>\u7528\u6237\u70b9\u8d5e \/ \u53d6\u6d88&#xff1a;\u4ec5\u64cd\u4f5c Redis Set&#xff0c;\u4e0d\u76f4\u63a5\u5199\u6570\u636e\u5e93&#xff1b;<\/li>\n<li>\u540c\u6b65\u66f4\u65b0 Redis ZSet&#xff1a;\u8bb0\u5f55\u4e1a\u52a1 ID \u4e0e\u6700\u65b0\u70b9\u8d5e\u6570&#xff1b;<\/li>\n<li>\u5b9a\u65f6\u4efb\u52a1&#xff1a;\u6bcf\u9694 20 \u79d2\u4ece ZSet \u4e2d\u53d6\u51fa\u5f85\u540c\u6b65\u6570\u636e&#xff0c;\u6279\u91cf\u53d1\u9001 MQ \u901a\u77e5\u4e1a\u52a1\u65b9&#xff1b;<\/li>\n<li>\u4e1a\u52a1\u65b9&#xff1a;\u76d1\u542c MQ \u6279\u91cf\u66f4\u65b0\u672c\u5730\u70b9\u8d5e\u6570&#xff0c;\u5b8c\u6210\u6700\u7ec8\u6301\u4e45\u5316\u3002<\/li>\n<\/ul>\n<p>\u8fd9\u91cc\u7ed9\u4e24\u5e45\u56fe&#xff0c;\u4e00\u4efd\u9ed1\u9a6c\u7684&#xff0c;\u4e00\u4efd\u6309\u6211\u81ea\u5df1\u7684\u7406\u89e3\u753b&#xff08;\u5176\u5b9e\u611f\u89c9\u9ed1\u9a6c\u7684\u6709\u70b9\u62bd\u8c61&#xff09;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"481\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260128143254-697a1e160c20b.png\" width=\"1280\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"516\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260128143254-697a1e16473f5.png\" width=\"1303\" \/><\/p>\n<h4 id=\"2.2.2Redis%20%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E9%80%89%E5%9E%8B\">2.2.2Redis \u6570\u636e\u7ed3\u6784\u9009\u578b<\/h4>\n<p>\u57fa\u4e8e\u70b9\u8d5e\u4e1a\u52a1\u7684\u4e24\u4e2a\u6838\u5fc3\u6570\u636e&#xff08;\u7528\u6237\u70b9\u8d5e\u8bb0\u5f55\u3001\u4e1a\u52a1\u70b9\u8d5e\u6570&#xff09;&#xff0c;\u6211\u4eec\u9009\u62e9\u4e24\u79cd Redis \u6570\u636e\u7ed3\u6784&#xff1a;<\/p>\n<table>\n<tr>\u6570\u636e\u7c7b\u578b\u6570\u636e\u7ed3\u6784Key \u8bbe\u8ba1\u6838\u5fc3\u4f5c\u7528<\/tr>\n<tbody>\n<tr>\n<td>\u7528\u6237\u70b9\u8d5e\u8bb0\u5f55<\/td>\n<td>Set<\/td>\n<td>likes:set:biz:{bizId}<\/td>\n<td>\u5b58\u50a8\u7ed9\u67d0\u4e1a\u52a1\u70b9\u8d5e\u7684\u6240\u6709\u7528\u6237 ID&#xff0c;\u5229\u7528 Set \u7684\u552f\u4e00\u6027\u9632\u91cd\u590d\u70b9\u8d5e&#xff0c;SCARD \u5feb\u901f\u7edf\u8ba1\u603b\u6570<\/td>\n<\/tr>\n<tr>\n<td>\u5f85\u540c\u6b65\u70b9\u8d5e\u6570<\/td>\n<td>ZSet<\/td>\n<td>likes:times:type:{bizType}<\/td>\n<td>\u5b58\u50a8\u4e1a\u52a1 ID \u4e0e\u6700\u65b0\u70b9\u8d5e\u6570&#xff0c;\u5229\u7528 ZSet \u7684 member \u552f\u4e00\u6027\u907f\u514d\u91cd\u590d\u540c\u6b65<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u9009\u578b\u6df1\u5c42\u601d\u8003&#xff1a;<\/p>\n<ul>\n<li>Set \u5b58\u70b9\u8d5e\u8bb0\u5f55&#xff1a;SADD\/SREM \u539f\u5b50\u6027\u64cd\u4f5c\u4fdd\u8bc1\u70b9\u8d5e \/ \u53d6\u6d88\u7684\u5b89\u5168\u6027&#xff0c;SISMEMBER \u5224\u65ad\u70b9\u8d5e\u72b6\u6001&#xff0c;SCARD O (1) \u65f6\u95f4\u590d\u6742\u5ea6\u7edf\u8ba1\u603b\u6570&#xff0c;\u6027\u80fd\u8fdc\u8d85\u6570\u636e\u5e93 count&#xff1b;<\/li>\n<li>ZSet \u5b58\u5f85\u540c\u6b65\u6570&#xff1a;\u5176\u5b9e\u8fd9\u91ccHash\u548cZSet\u90fd\u53ef\u4ee5&#xff0c;\u800c\u4e14\u5982\u679c\u662f\u4ece\u8282\u7701\u5185\u5b58\u89d2\u5ea6\u6765\u8003\u8651&#xff0c;Hash\u7ed3\u6784\u65e0\u7591\u662f\u6700\u4f73\u7684\u9009\u62e9&#xff1b;\u4f46\u662f\u8003\u8651\u5230<span style=\"color:#fe2c24\">\u5c06\u6765\u6211\u4eec\u8981\u4eceRedis\u8bfb\u53d6\u70b9\u8d5e\u6570&#xff0c;\u7136\u540e\u79fb\u9664&#xff08;\u907f\u514d\u91cd\u590d\u5904\u7406&#xff09;<\/span>\u3002\u4e3a\u4e86\u4fdd\u8bc1\u7ebf\u7a0b\u5b89\u5168&#xff0c;\u67e5\u8be2\u3001\u79fb\u9664\u64cd\u4f5c\u5fc5\u987b\u5177\u5907\u539f\u5b50\u6027\u3002\u800cSortedSet\u5219\u63d0\u4f9b\u4e86\u51e0\u4e2a\u79fb\u9664\u5e76\u83b7\u53d6\u7684\u529f\u80fd&#xff0c;\u5929\u751f\u5177\u5907\u539f\u5b50\u6027\u3002\u5e76\u4e14\u6211\u4eec\u6bcf\u9694\u4e00\u6bb5\u65f6\u95f4\u5c31\u4f1a\u5c06\u6570\u636e\u4eceRedis\u79fb\u9664&#xff0c;\u5e76\u4e0d\u4f1a\u5360\u7528\u592a\u591a\u5185\u5b58\u3002\u56e0\u6b64&#xff0c;\u8fd9\u91cc\u6211\u4eec\u8ba1\u5212\u4f7f\u7528SortedSet\u7ed3\u6784<\/li>\n<\/ul>\n<p>\u4e24\u79cdRedis\u7ed3\u6784\u793a\u4f8b\u5982\u4e0b&#xff1a;<\/p>\n<p>\u70b9\u8d5e\u8bb0\u5f55&#xff08;\u5224\u65ad\u7528\u6237\u662f\u5426\u70b9\u8d5e&#xff09;<\/p>\n<table>\n<tr>\n<p>KEY&#xff08;bizId&#xff09;<\/p>\n<p>VALUE(userId)<\/p>\n<\/tr>\n<tbody>\n<tr>\n<td colspan=\"1\" rowspan=\"3\">\n<p>bizId:1<\/p>\n<\/td>\n<td colspan=\"1\" rowspan=\"1\">\n<p>userId:1<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td colspan=\"1\" rowspan=\"1\">\n<p>userId:2<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td colspan=\"1\" rowspan=\"1\">\n<p>userId:3<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u70b9\u8d5e\u6570\u91cf<\/p>\n<table>\n<tr>\n<p>KEY&#xff08;bizType&#xff09;<\/p>\n<p>Member(bizId)<\/p>\n<p>Score(likedTimes)<\/p>\n<\/tr>\n<tbody>\n<tr>\n<td colspan=\"1\" rowspan=\"2\">\n<p>likes:qa<\/p>\n<\/td>\n<td colspan=\"1\" rowspan=\"1\">\n<p>bizId:1001<\/p>\n<\/td>\n<td colspan=\"1\" rowspan=\"1\">\n<p>10<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td colspan=\"1\" rowspan=\"1\">\n<p>bizId:1002<\/p>\n<\/td>\n<td colspan=\"1\" rowspan=\"1\">\n<p>5<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td colspan=\"1\" rowspan=\"2\">\n<p>likes:note<\/p>\n<\/td>\n<td colspan=\"1\" rowspan=\"1\">\n<p>bizId:2001<\/p>\n<\/td>\n<td colspan=\"1\" rowspan=\"1\">\n<p>9<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td colspan=\"1\" rowspan=\"1\">\n<p>bizId:2002<\/p>\n<\/td>\n<td colspan=\"1\" rowspan=\"1\">\n<p>21<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3 id=\"2.3%E4%BB%A3%E7%A0%81%E5%AE%9E%E7%8E%B0\">2.3\u4ee3\u7801\u5b9e\u73b0<\/h3>\n<h4 id=\"2.3.1%E4%BB%A3%E7%A0%81%E5%AE%9E%E7%8E%B0%E6%B5%81%E7%A8%8B%E5%9B%BE\">2.3.1\u4ee3\u7801\u5b9e\u73b0\u6d41\u7a0b\u56fe<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"538\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260128143254-697a1e168b565.png\" width=\"1119\" \/><\/p>\n<h4 id=\"2.3.2%E6%A0%B8%E5%BF%83%E6%8E%A5%E5%8F%A3%E6%94%B9%E9%80%A0%EF%BC%88%E7%82%B9%E8%B5%9E%20%2F%20%E5%8F%96%E6%B6%88%EF%BC%89\">2.3.2\u6838\u5fc3\u63a5\u53e3\u6539\u9020&#xff08;\u70b9\u8d5e \/ \u53d6\u6d88&#xff09;<\/h4>\n<p>\u66ff\u6362\u539f\u6709\u7684\u6570\u636e\u5e93\u64cd\u4f5c&#xff0c;\u6539\u4e3a Redis \u64cd\u4f5c&#xff0c;\u6838\u5fc3\u4ee3\u7801\u5982\u4e0b&#xff1a;<\/p>\n<p>&#064;Service<br \/>\npublic class LikedRecordServiceRedisImpl implements ILikedRecordService {<br \/>\n    private final StringRedisTemplate redisTemplate;<\/p>\n<p>    &#064;Override<br \/>\n    public void addLikeRecord(LikeRecordFormDTO recordDTO) {<br \/>\n        \/\/ 1. \u70b9\u8d5e\/\u53d6\u6d88\u70b9\u8d5e&#xff08;\u64cd\u4f5cRedis Set&#xff09;<br \/>\n        boolean success &#061; recordDTO.getLiked() ? like(recordDTO) : unlike(recordDTO);<br \/>\n        if (!success) return;<br \/>\n        \/\/ 2. \u7edf\u8ba1Redis\u4e2d\u70b9\u8d5e\u603b\u6570<br \/>\n        Long likedTimes &#061; redisTemplate.opsForSet()<br \/>\n                .size(RedisConstants.LIKE_BIZ_KEY_PREFIX &#043; recordDTO.getBizId());<br \/>\n        if (likedTimes &#061;&#061; null) return;<br \/>\n        \/\/ 3. \u66f4\u65b0ZSet\u5f85\u540c\u6b65\u6570\u636e<br \/>\n        redisTemplate.opsForZSet().add(<br \/>\n                RedisConstants.LIKES_TIMES_KEY_PREFIX &#043; recordDTO.getBizType(),<br \/>\n                recordDTO.getBizId().toString(),<br \/>\n                likedTimes<br \/>\n        );<br \/>\n    }<\/p>\n<p>    \/\/ \u70b9\u8d5e&#xff1a;SADD\u8fd4\u56de1\u5219\u6210\u529f&#xff08;\u672a\u70b9\u8d5e\u8fc7&#xff09;&#xff0c;0\u5219\u5931\u8d25&#xff08;\u91cd\u590d\u70b9\u8d5e&#xff09;<br \/>\n    private boolean like(LikeRecordFormDTO recordDTO) {<br \/>\n        String key &#061; RedisConstants.LIKE_BIZ_KEY_PREFIX &#043; recordDTO.getBizId();<br \/>\n        Long result &#061; redisTemplate.opsForSet().add(key, UserContext.getUser().toString());<br \/>\n        return result !&#061; null &amp;&amp; result &gt; 0;<br \/>\n    }<\/p>\n<p>    \/\/ \u53d6\u6d88\u70b9\u8d5e&#xff1a;SREM\u8fd4\u56de1\u5219\u6210\u529f&#xff08;\u5df2\u70b9\u8d5e&#xff09;&#xff0c;0\u5219\u5931\u8d25<br \/>\n    private boolean unlike(LikeRecordFormDTO recordDTO) {<br \/>\n        String key &#061; RedisConstants.LIKE_BIZ_KEY_PREFIX &#043; recordDTO.getBizId();<br \/>\n        Long result &#061; redisTemplate.opsForSet().remove(key, UserContext.getUser().toString());<br \/>\n        return result !&#061; null &amp;&amp; result &gt; 0;<br \/>\n    }<br \/>\n} <\/p>\n<h4 id=\"2.3.3Pipeline%20%E4%BC%98%E5%8C%96%E6%89%B9%E9%87%8F%E6%9F%A5%E8%AF%A2%E6%80%A7%E8%83%BD\">2.3.3Pipeline \u4f18\u5316\u6279\u91cf\u67e5\u8be2\u6027\u80fd<\/h4>\n<p>\u6279\u91cf\u67e5\u8be2\u70b9\u8d5e\u72b6\u6001\u65f6&#xff0c;\u82e5\u9010\u4e2a\u8c03\u7528 SISMEMBER&#xff0c;\u4f1a\u4ea7\u751f\u591a\u6b21 Redis \u7f51\u7edc\u4ea4\u4e92\u3002\u6211\u4eec\u4f7f\u7528 Redis Pipeline \u5c06\u591a\u4e2a\u547d\u4ee4\u6253\u5305\u53d1\u9001&#xff0c;\u4e00\u6b21\u7f51\u7edc\u5f80\u8fd4\u5b8c\u6210\u6240\u6709\u67e5\u8be2&#xff1a;<\/p>\n<p>&#064;Override<br \/>\npublic Set&lt;Long&gt; isBizLiked(List&lt;Long&gt; bizIds) {<br \/>\n    Long userId &#061; UserContext.getUser();<br \/>\n    \/\/ Pipeline\u6279\u91cf\u6267\u884cSISMEMBER<br \/>\n    List&lt;Object&gt; results &#061; redisTemplate.executePipelined((RedisCallback&lt;Object&gt;) connection -&gt; {<br \/>\n        StringRedisConnection src &#061; (StringRedisConnection) connection;<br \/>\n        for (Long bizId : bizIds) {<br \/>\n            String key &#061; RedisConstants.LIKE_BIZ_KEY_PREFIX &#043; bizId;<br \/>\n            src.sIsMember(key, userId.toString());<br \/>\n        }<br \/>\n        return null;<br \/>\n    });<br \/>\n    \/\/ \u8fc7\u6ee4\u51fa\u70b9\u8d5e\u8fc7\u7684\u4e1a\u52a1ID<br \/>\n    return IntStream.range(0, results.size())<br \/>\n            .filter(i -&gt; (boolean) results.get(i))<br \/>\n            .mapToObj(bizIds::get)<br \/>\n            .collect(Collectors.toSet());<br \/>\n} <\/p>\n<h4 id=\"2.3.4%20%E5%AE%9A%E6%97%B6%E4%BB%BB%E5%8A%A1%E6%89%B9%E9%87%8F%E5%90%8C%E6%AD%A5%E7%82%B9%E8%B5%9E%E6%95%B0\">2.3.4 \u5b9a\u65f6\u4efb\u52a1\u6279\u91cf\u540c\u6b65\u70b9\u8d5e\u6570<\/h4>\n<p>\u4f7f\u7528 SpringTask \u5b9e\u73b0\u5b9a\u65f6\u4efb\u52a1&#xff0c;\u6bcf\u9694 20 \u79d2\u4ece ZSet \u4e2d\u53d6\u51fa\u5f85\u540c\u6b65\u6570\u636e&#xff0c;\u6279\u91cf\u53d1\u9001 MQ&#xff1a;<\/p>\n<p>&#064;Component<br \/>\npublic class LikedTimesCheckTask {<br \/>\n    \/\/ \u652f\u6301\u7684\u4e1a\u52a1\u7c7b\u578b&#xff08;\u53ef\u914d\u7f6e\u5316&#xff09;<br \/>\n    private static final List&lt;String&gt; BIZ_TYPES &#061; List.of(&#034;QA&#034;, &#034;NOTE&#034;);<br \/>\n    private static final int MAX_BIZ_SIZE &#061; 30; \/\/ \u5355\u6b21\u6700\u5927\u540c\u6b65\u6570\u91cf<\/p>\n<p>    &#064;Scheduled(fixedDelay &#061; 20000) \/\/ 20\u79d2\u6267\u884c\u4e00\u6b21<br \/>\n    public void checkLikedTimes(){<br \/>\n        for (String bizType : BIZ_TYPES) {<br \/>\n            recordService.readLikedTimesAndSendMessage(bizType, MAX_BIZ_SIZE);<br \/>\n        }<br \/>\n    }<br \/>\n}<\/p>\n<p>\/\/ \u6838\u5fc3\u540c\u6b65\u903b\u8f91<br \/>\n&#064;Override<br \/>\npublic void readLikedTimesAndSendMessage(String bizType, int maxBizSize) {<br \/>\n    String key &#061; RedisConstants.LIKES_TIMES_KEY_PREFIX &#043; bizType;<br \/>\n    \/\/ \u4eceZSet\u4e2d\u53d6\u51fa\u5e76\u5220\u9664\u524dN\u6761\u6570\u636e&#xff08;\u539f\u5b50\u64cd\u4f5c&#xff09;<br \/>\n    Set&lt;ZSetOperations.TypedTuple&lt;String&gt;&gt; tuples &#061; redisTemplate.opsForZSet().popMin(key, maxBizSize);<br \/>\n    if (CollUtils.isEmpty(tuples)) return;<br \/>\n    \/\/ \u8f6c\u6362\u4e3aMQ\u6d88\u606f\u4f53<br \/>\n    List&lt;LikedTimesDTO&gt; list &#061; tuples.stream()<br \/>\n            .filter(t -&gt; t.getValue() !&#061; null &amp;&amp; t.getScore() !&#061; null)<br \/>\n            .map(t -&gt; LikedTimesDTO.of(Long.valueOf(t.getValue()), t.getScore().intValue()))<br \/>\n            .collect(Collectors.toList());<br \/>\n    \/\/ \u6279\u91cf\u53d1\u9001MQ<br \/>\n    mqHelper.send(LIKE_RECORD_EXCHANGE,<br \/>\n            StringUtils.format(LIKED_TIMES_KEY_TEMPLATE, bizType), list);<br \/>\n} <\/p>\n<h2 id=\"3.%E8%BF%9B%E4%B8%80%E6%AD%A5%E4%BC%98%E5%8C%96%EF%BC%9A%E5%AE%9A%E6%9C%9F%E6%8C%81%E4%B9%85%E5%8C%96%E5%88%B0%E6%95%B0%E6%8D%AE%E5%BA%93%EF%BC%8C%E9%87%87%E7%94%A8LRU%E7%A7%BB%E9%99%A4%E6%9C%80%E8%BF%91%E6%9C%80%E5%B0%91%E8%AE%BF%E9%97%AE\">3.\u8fdb\u4e00\u6b65\u4f18\u5316&#xff1a;\u5b9a\u671f\u6301\u4e45\u5316\u5230\u6570\u636e\u5e93&#xff0c;\u91c7\u7528LRU\u79fb\u9664\u6700\u8fd1\u6700\u5c11\u8bbf\u95ee<\/h2>\n<h3 id=\"3.1%E5%AE%9A%E4%B9%89%E6%96%B0%E7%9A%84Redis%E7%BB%93%E6%9E%84%E7%94%A8%E4%BA%8E%E5%AE%9E%E7%8E%B0LRU%E5%92%8C%E6%8C%81%E4%B9%85%E5%8C%96\">3.1\u5b9a\u4e49\u65b0\u7684Redis\u7ed3\u6784\u7528\u4e8e\u5b9e\u73b0LRU\u548c\u6301\u4e45\u5316<\/h3>\n<h4 id=\"3.1.1LRU%20%E8%AE%BF%E9%97%AE%E7%AD%96%E7%95%A5%E8%A1%A8\"><span style=\"color:null\">3.1.1LRU \u8bbf\u95ee\u7b56\u7565\u8868<\/span><\/h4>\n<p>\u7528\u4e8e\u5b58\u50a8 \u6bcf\u4e2a\u4e1a\u52a1\u6700\u540e\u4e00\u6b21\u88ab\u8bbf\u95ee&#xff08;\u70b9\u8d5e\/\u67e5\u8be2&#xff09;\u7684\u65f6\u95f4\u6233 \u3002Score \u8d8a\u5c0f\u4ee3\u8868\u8d8a\u4e45\u6ca1\u8bbf\u95ee&#xff08;\u51b7\u6570\u636e&#xff09;\u3002<\/p>\n<table>\n<tr>KEY&#xff08;likes:access:strategy&#xff09;MEMBER&#xff08;bizId&#xff09;SCORE&#xff08;timestamp&#xff09;\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td colspan=\"1\" rowspan=\"3\">likes:access:strategy<\/td>\n<td>102<\/td>\n<td>1735689600000<\/td>\n<td>\u4e1a\u52a1 102 \u6700\u540e\u8bbf\u95ee\u4e8e 08:00&#xff08;\u6700\u51b7&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>101<\/td>\n<td>1735691400000<\/td>\n<td>\u4e1a\u52a1 101 \u6700\u540e\u8bbf\u95ee\u4e8e 08:30<\/td>\n<\/tr>\n<tr>\n<td>103<\/td>\n<td>1735693200000<\/td>\n<td>\u4e1a\u52a1 103 \u6700\u540e\u8bbf\u95ee\u4e8e 09:00&#xff08;\u6700\u70ed&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4 id=\"3.1.2%E4%B8%9A%E5%8A%A1%E7%B1%BB%E5%9E%8B%E6%98%A0%E5%B0%84%E8%A1%A8%20(Hash)\">3.1.2\u4e1a\u52a1\u7c7b\u578b\u6620\u5c04\u8868 (Hash)<\/h4>\n<p>\u7528\u4e8e\u5b58\u50a8 \u4e1a\u52a1ID\u5bf9\u5e94\u7684\u4e1a\u52a1\u7c7b\u578b &#xff0c;\u786e\u4fdd\u6301\u4e45\u5316\u65f6\u80fd\u77e5\u9053\u6bcf\u4e2a ID \u662f\u4ec0\u4e48\u7c7b\u578b\u7684\u4e1a\u52a1\u3002<\/p>\n<table>\n<tr>KEY&#xff08;likes:biz:type&#xff09;FIELD&#xff08;bizId&#xff09;VALUE&#xff08;bizType&#xff09;\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>likes:biz:type<\/td>\n<td>101<\/td>\n<td>&#034;QA&#034;<\/td>\n<td>\u4e1a\u52a1 101 \u662f\u95ee\u7b54\u7c7b\u578b<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td>102<\/td>\n<td>&#034;NOTE&#034;<\/td>\n<td>\u4e1a\u52a1 102 \u662f\u7b14\u8bb0\u7c7b\u578b<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td>103<\/td>\n<td>&#034;QA&#034;<\/td>\n<td>\u4e1a\u52a1 103 \u662f\u95ee\u7b54\u7c7b\u578b<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3 id=\"3.2%E4%B8%9A%E5%8A%A1%E6%B5%81%E7%A8%8B\">3.2\u4e1a\u52a1\u6d41\u7a0b<\/h3>\n<h4 id=\"3.2.1%E5%AE%9E%E6%97%B6%E4%BA%A4%E4%BA%92%E6%B5%81%E7%A8%8B\">3.2.1\u5b9e\u65f6\u4ea4\u4e92\u6d41\u7a0b<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"892\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260128143254-697a1e16cefbd.png\" width=\"640\" \/><\/p>\n<p>\u2460 \u70b9\u8d5e \/ \u53d6\u6d88\u70b9\u8d5e<\/p>\n<ul>\n<li>&#8211; \u64cd\u4f5c Redis \u96c6\u5408 : \u7528\u6237\u8bf7\u6c42\u5230\u8fbe\u540e&#xff0c;\u76f4\u63a5\u5728 Redis \u7684 Set \u96c6\u5408\u4e2d\u6dfb\u52a0 ( SADD ) \u6216\u79fb\u9664 ( SREM ) \u7528\u6237ID&#xff0c;\u4fdd\u8bc1\u6781\u901f\u54cd\u5e94\u3002<\/li>\n<li>&#8211; \u66f4\u65b0 LRU \u70ed\u5ea6 : \u5c06\u8be5\u4e1a\u52a1ID \u5728 likes:access:strategy (ZSet) \u4e2d\u7684\u5206\u6570\u66f4\u65b0\u4e3a\u5f53\u524d\u65f6\u95f4\u6233&#xff0c;\u6807\u8bb0\u4e3a\u201c\u6700\u8fd1\u6d3b\u8dc3\u201d\u3002<\/li>\n<li>&#8211; \u8bb0\u5f55\u5143\u6570\u636e : \u5728 likes:biz:type (Hash) \u4e2d\u8bb0\u5f55\u8be5\u4e1a\u52a1ID\u5bf9\u5e94\u7684\u4e1a\u52a1\u7c7b\u578b&#xff0c;\u9632\u6b62\u6301\u4e45\u5316\u65f6\u4e22\u5931\u7c7b\u578b\u4fe1\u606f\u3002<\/li>\n<li>&#8211; \u7edf\u8ba1\u603b\u6570 : \u66f4\u65b0\u8be5\u4e1a\u52a1\u7c7b\u578b\u7684\u70b9\u8d5e\u6392\u884c\u699c\u6570\u636e\u3002<\/li>\n<\/ul>\n<p>\u2461\u67e5\u8be2\u70b9\u8d5e\u72b6\u6001<\/p>\n<ul>\n<li>&#8211; \u7f13\u5b58\u68c0\u67e5 : \u7cfb\u7edf\u9996\u5148\u68c0\u67e5\u8bf7\u6c42\u7684\u4e1a\u52a1ID\u662f\u5426\u5728 Redis \u4e2d\u5b58\u5728\u3002<\/li>\n<li>&#8211; \u7f13\u5b58\u56de\u586b (Cache Warming) :\n<ul>\n<li>\u00a0 &#8211; \u5982\u679c Redis \u4e2d \u6ca1\u6709 \u6570\u636e&#xff08;\u8bf4\u660e\u662f\u51b7\u6570\u636e\u6216\u5df2\u88ab\u6dd8\u6c70&#xff09;&#xff0c;\u5219\u89e6\u53d1\u201c\u56de\u586b\u673a\u5236\u201d\u3002<\/li>\n<li>\u00a0 &#8211; \u7cfb\u7edf\u81ea\u52a8\u53bb MySQL \u67e5\u8be2\u8be5\u4e1a\u52a1\u7684\u6240\u6709\u70b9\u8d5e\u8bb0\u5f55&#xff0c;\u91cd\u5efa Redis Set&#xff0c;\u5e76\u8865\u5168\u5143\u6570\u636e\u3002<\/li>\n<\/ul>\n<\/li>\n<li>&#8211; \u5237\u65b0\u70ed\u5ea6 : \u65e0\u8bba\u6570\u636e\u6765\u81ea\u7f13\u5b58\u8fd8\u662f\u6570\u636e\u5e93&#xff0c;\u672c\u6b21\u67e5\u8be2\u6d89\u53ca\u7684\u6240\u6709\u4e1a\u52a1ID&#xff0c;\u5176 LRU \u65f6\u95f4\u6233\u90fd\u4f1a\u88ab\u66f4\u65b0\u4e3a\u6700\u65b0\u65f6\u95f4&#xff0c;\u9632\u6b62\u88ab\u7acb\u523b\u6dd8\u6c70\u3002<\/li>\n<li>&#8211; \u8fd4\u56de\u7ed3\u679c : \u6700\u7ec8\u7edf\u4e00\u4ece Redis Set \u4e2d\u5224\u65ad\u5e76\u8fd4\u56de\u72b6\u6001\u3002<\/li>\n<\/ul>\n<h4 id=\"3.2.2%E5%BC%82%E6%AD%A5%E6%8C%81%E4%B9%85%E5%8C%96%E6%B5%81%E7%A8%8B\">3.2.2\u5f02\u6b65\u6301\u4e45\u5316\u6d41\u7a0b<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"902\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260128143254-697a1e16ec1de.png\" width=\"484\" \/><\/p>\n<p>\u5b9a\u65f6\u4efb\u52a1 (\u6bcf 3\u5206\u949f\u6267\u884c\u4e00\u6b21&#xff0c;\u8fd9\u91cc\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u8fdb\u884c\u8c03\u6574)<\/p>\n<p>1. \u5bb9\u91cf\u68c0\u67e5 : \u68c0\u67e5 LRU ZSet \u8bb0\u5f55\u7684\u6570\u91cf\u662f\u5426\u8d85\u8fc7\u6700\u5927\u9608\u503c (\u5982 10000)\u3002 2. \u7b5b\u9009\u51b7\u6570\u636e : \u5982\u679c\u8d85\u9650&#xff0c;\u6309\u5206\u6570\u4ece\u5c0f\u5230\u5927 (\u65f6\u95f4\u4ece\u65e7\u5230\u65b0) \u6293\u53d6\u6700\u4e45\u672a\u8bbf\u95ee\u7684\u4e00\u6279\u4e1a\u52a1ID\u3002 3. \u6570\u636e\u540c\u6b65 (Diff &amp; Sync) : \u00a0 \u00a0&#8211; \u5bf9\u4e8e\u6bcf\u4e2a\u51b7\u4e1a\u52a1ID&#xff0c;\u53d6\u51fa Redis \u4e2d\u7684\u7528\u6237\u5217\u8868\u4e0e DB \u4e2d\u7684\u7528\u6237\u5217\u8868\u3002 \u00a0 \u00a0&#8211; \u8ba1\u7b97\u5dee\u5f02 : \u627e\u51fa Redis \u4e2d\u65b0\u589e\u7684\u7528\u6237 (\u9700\u63d2\u5165 DB) \u548c Redis \u4e2d\u5df2\u79fb\u9664\u7684\u7528\u6237 (\u9700\u4ece DB \u5220\u9664)\u3002 \u00a0 \u00a0&#8211; \u6279\u91cf\u843d\u5e93 : \u6267\u884c\u6570\u636e\u5e93\u7684\u63d2\u5165\u548c\u5220\u9664\u64cd\u4f5c&#xff0c;\u786e\u4fdd\u6570\u636e\u4e00\u81f4\u3002 4. \u5185\u5b58\u91ca\u653e : \u540c\u6b65\u6210\u529f\u540e&#xff0c;\u5f7b\u5e95\u5220\u9664 Redis \u4e2d\u7684\u76f8\u5173 Key (Set, Hash, ZSet)&#xff0c;\u91ca\u653e\u5185\u5b58\u7a7a\u95f4\u3002<\/p>\n<h3 id=\"3.3%E4%BB%A3%E7%A0%81%E5%AE%9E%E7%8E%B0\">3.3\u4ee3\u7801\u5b9e\u73b0<\/h3>\n<p>package com.tianji.remark.service.impl;<\/p>\n<p>import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;<br \/>\nimport com.tianji.api.dto.remark.LikedTimesDTO;<br \/>\nimport com.tianji.common.autoconfigure.mq.RabbitMqHelper;<br \/>\nimport com.tianji.common.utils.CollUtils;<br \/>\nimport com.tianji.common.utils.StringUtils;<br \/>\nimport com.tianji.common.utils.UserContext;<br \/>\nimport com.tianji.remark.constants.RedisConstants;<br \/>\nimport com.tianji.remark.domain.dto.LikeRecordFormDTO;<br \/>\nimport com.tianji.remark.domain.po.LikedRecord;<br \/>\nimport com.tianji.remark.mapper.LikedRecordMapper;<br \/>\nimport com.tianji.remark.service.ILikedRecordService;<br \/>\nimport lombok.RequiredArgsConstructor;<br \/>\nimport org.springframework.data.redis.connection.StringRedisConnection;<br \/>\nimport org.springframework.data.redis.core.RedisCallback;<br \/>\nimport org.springframework.data.redis.core.StringRedisTemplate;<br \/>\nimport org.springframework.data.redis.core.ZSetOperations;<br \/>\nimport org.springframework.stereotype.Service;<br \/>\nimport org.springframework.transaction.annotation.Transactional;<\/p>\n<p>import java.util.*;<br \/>\nimport java.util.stream.Collectors;<br \/>\nimport java.util.stream.IntStream;<\/p>\n<p>import static com.tianji.common.constants.MqConstants.Exchange.LIKE_RECORD_EXCHANGE;<br \/>\nimport static com.tianji.common.constants.MqConstants.Key.LIKED_TIMES_KEY_TEMPLATE;<\/p>\n<p>\/**<br \/>\n * &lt;p&gt;<br \/>\n * \u70b9\u8d5e\u8bb0\u5f55\u8868 \u670d\u52a1\u5b9e\u73b0\u7c7b<br \/>\n * &lt;\/p&gt;<br \/>\n *\/<br \/>\n&#064;Service<br \/>\n&#064;RequiredArgsConstructor<br \/>\npublic class LikedRecordServiceRedisImpl extends ServiceImpl&lt;LikedRecordMapper, LikedRecord&gt; implements ILikedRecordService {<\/p>\n<p>    private final RabbitMqHelper mqHelper;<br \/>\n    private final StringRedisTemplate redisTemplate;<\/p>\n<p>    &#064;Override<br \/>\n    public void addLikeRecord(LikeRecordFormDTO recordDTO) {<br \/>\n        \/\/ 1.\u57fa\u4e8e\u524d\u7aef\u7684\u53c2\u6570&#xff0c;\u5224\u65ad\u662f\u6267\u884c\u70b9\u8d5e\u8fd8\u662f\u53d6\u6d88\u70b9\u8d5e<br \/>\n        boolean success &#061; recordDTO.getLiked() ? like(recordDTO) : unlike(recordDTO);<br \/>\n        \/\/ 2.\u5224\u65ad\u662f\u5426\u6267\u884c\u6210\u529f&#xff0c;\u5982\u679c\u5931\u8d25&#xff0c;\u5219\u76f4\u63a5\u7ed3\u675f<br \/>\n        if (!success) {<br \/>\n            return;<br \/>\n        }<\/p>\n<p>        \/\/ \u66f4\u65b0\u8bbf\u95ee\u65f6\u95f4(LRU) \u548c \u4e1a\u52a1\u7c7b\u578b\u6620\u5c04<br \/>\n        String bizIdStr &#061; recordDTO.getBizId().toString();<br \/>\n        redisTemplate.opsForZSet().add(RedisConstants.LIKES_ACCESS_STRATEGY_KEY, bizIdStr, System.currentTimeMillis());<br \/>\n        redisTemplate.opsForHash().put(RedisConstants.LIKES_BIZ_TYPE_MAP_KEY, bizIdStr, recordDTO.getBizType());<\/p>\n<p>        \/\/ 3.\u5982\u679c\u6267\u884c\u6210\u529f&#xff0c;\u7edf\u8ba1\u70b9\u8d5e\u603b\u6570<br \/>\n        Long likedTimes &#061; redisTemplate.opsForSet()<br \/>\n                .size(RedisConstants.LIKE_BIZ_KEY_PREFIX &#043; recordDTO.getBizId());<br \/>\n        if (likedTimes &#061;&#061; null) {<br \/>\n            return;<br \/>\n        }<br \/>\n        \/\/ 4.\u7f13\u5b58\u70b9\u603b\u6570\u5230Redis<br \/>\n        redisTemplate.opsForZSet().add(<br \/>\n                RedisConstants.LIKES_TIMES_KEY_PREFIX &#043; recordDTO.getBizType(),<br \/>\n                recordDTO.getBizId().toString(),<br \/>\n                likedTimes<br \/>\n        );<br \/>\n    }<\/p>\n<p>    &#064;Override<br \/>\n    public Set&lt;Long&gt; isBizLiked(List&lt;Long&gt; bizIds) {<br \/>\n        \/\/ 1.\u83b7\u53d6\u767b\u5f55\u7528\u6237id<br \/>\n        Long userId &#061; UserContext.getUser();<\/p>\n<p>        \/\/ 2.\u68c0\u67e5Redis\u4e2d\u662f\u5426\u5b58\u5728 key&#xff0c;\u4e0d\u5b58\u5728\u5219\u5c1d\u8bd5\u4ece\u6570\u636e\u5e93\u52a0\u8f7d<br \/>\n        List&lt;Long&gt; missingBizIds &#061; new ArrayList&lt;&gt;();<br \/>\n        \/\/ \u4f7f\u7528pipeline\u6279\u91cf\u5224\u65adkey\u662f\u5426\u5b58\u5728<br \/>\n        List&lt;Object&gt; existsResults &#061; redisTemplate.executePipelined((RedisCallback&lt;Object&gt;) connection -&gt; {<br \/>\n            StringRedisConnection src &#061; (StringRedisConnection) connection;<br \/>\n            for (Long bizId : bizIds) {<br \/>\n                src.exists(RedisConstants.LIKE_BIZ_KEY_PREFIX &#043; bizId);<br \/>\n            }<br \/>\n            return null;<br \/>\n        });<\/p>\n<p>        for (int i &#061; 0; i &lt; bizIds.size(); i&#043;&#043;) {<br \/>\n            Boolean exists &#061; (Boolean) existsResults.get(i);<br \/>\n            if (exists &#061;&#061; null || !exists) {<br \/>\n                missingBizIds.add(bizIds.get(i));<br \/>\n            }<br \/>\n        }<\/p>\n<p>        if (!missingBizIds.isEmpty()) {<br \/>\n            loadBizLikesFromDb(missingBizIds);<br \/>\n        }<\/p>\n<p>        \/\/ 3.\u66f4\u65b0LRU\u8bbf\u95ee\u65f6\u95f4<br \/>\n        long now &#061; System.currentTimeMillis();<br \/>\n        redisTemplate.executePipelined((RedisCallback&lt;Object&gt;) connection -&gt; {<br \/>\n            StringRedisConnection src &#061; (StringRedisConnection) connection;<br \/>\n            for (Long bizId : bizIds) {<br \/>\n                src.zAdd(RedisConstants.LIKES_ACCESS_STRATEGY_KEY, now, bizId.toString());<br \/>\n            }<br \/>\n            return null;<br \/>\n        });<\/p>\n<p>        \/\/ 4.\u67e5\u8be2\u70b9\u8d5e\u72b6\u6001<br \/>\n        List&lt;Object&gt; objects &#061; redisTemplate.executePipelined((RedisCallback&lt;Object&gt;) connection -&gt; {<br \/>\n            StringRedisConnection src &#061; (StringRedisConnection) connection;<br \/>\n            for (Long bizId : bizIds) {<br \/>\n                String key &#061; RedisConstants.LIKE_BIZ_KEY_PREFIX &#043; bizId;<br \/>\n                src.sIsMember(key, userId.toString());<br \/>\n            }<br \/>\n            return null;<br \/>\n        });<br \/>\n        \/\/ 5.\u8fd4\u56de\u7ed3\u679c<br \/>\n        return IntStream.range(0, objects.size()) \/\/ \u521b\u5efa\u4ece0\u5230\u96c6\u5408size\u7684\u6d41<br \/>\n                .filter(i -&gt; (boolean) objects.get(i)) \/\/ \u904d\u5386\u6bcf\u4e2a\u5143\u7d20&#xff0c;\u4fdd\u7559\u7ed3\u679c\u4e3atrue\u7684\u89d2\u6807i<br \/>\n                .mapToObj(bizIds::get)\/\/ \u7528\u89d2\u6807i\u53d6bizIds\u4e2d\u7684\u5bf9\u5e94\u6570\u636e&#xff0c;\u5c31\u662f\u70b9\u8d5e\u8fc7\u7684id<br \/>\n                .collect(Collectors.toSet());\/\/ \u6536\u96c6<br \/>\n    }<\/p>\n<p>    private void loadBizLikesFromDb(List&lt;Long&gt; bizIds) {<br \/>\n        \/\/ \u67e5\u8be2DB<br \/>\n        List&lt;LikedRecord&gt; list &#061; lambdaQuery().in(LikedRecord::getBizId, bizIds).list();<br \/>\n        if (CollUtils.isEmpty(list)) {<br \/>\n            return;<br \/>\n        }<\/p>\n<p>        \/\/ \u5206\u7ec4<br \/>\n        Map&lt;Long, List&lt;LikedRecord&gt;&gt; map &#061; list.stream().collect(Collectors.groupingBy(LikedRecord::getBizId));<\/p>\n<p>        \/\/ \u5199\u5165Redis<br \/>\n        redisTemplate.executePipelined((RedisCallback&lt;Object&gt;) connection -&gt; {<br \/>\n            StringRedisConnection src &#061; (StringRedisConnection) connection;<br \/>\n            for (Map.Entry&lt;Long, List&lt;LikedRecord&gt;&gt; entry : map.entrySet()) {<br \/>\n                Long bizId &#061; entry.getKey();<br \/>\n                List&lt;LikedRecord&gt; records &#061; entry.getValue();<br \/>\n                if (CollUtils.isEmpty(records)) continue;<\/p>\n<p>                String key &#061; RedisConstants.LIKE_BIZ_KEY_PREFIX &#043; bizId;<br \/>\n                String[] userIds &#061; records.stream().map(r -&gt; r.getUserId().toString()).toArray(String[]::new);<br \/>\n                src.sAdd(key, userIds);<\/p>\n<p>                \/\/ \u7f13\u5b58\u4e1a\u52a1\u7c7b\u578b<br \/>\n                String bizType &#061; records.get(0).getBizType();<br \/>\n                src.hSet(RedisConstants.LIKES_BIZ_TYPE_MAP_KEY, bizId.toString(), bizType);<br \/>\n            }<br \/>\n            return null;<br \/>\n        });<br \/>\n    }<\/p>\n<p>    &#064;Override<br \/>\n    &#064;Transactional(rollbackFor &#061; Exception.class)<br \/>\n    public void persistOldRecords(int maxCapacity) {<br \/>\n        \/\/ 1.\u68c0\u67e5\u5bb9\u91cf\u662f\u5426\u8d85\u6807<br \/>\n        Long size &#061; redisTemplate.opsForZSet().zCard(RedisConstants.LIKES_ACCESS_STRATEGY_KEY);<br \/>\n        if (size &#061;&#061; null || size &lt;&#061; maxCapacity) {<br \/>\n            return;<br \/>\n        }<br \/>\n        long removeCount &#061; size &#8211; maxCapacity;<\/p>\n<p>        \/\/ 2.\u83b7\u53d6\u6700\u65e7\u7684\u8bb0\u5f55<br \/>\n        Set&lt;ZSetOperations.TypedTuple&lt;String&gt;&gt; tuples &#061; redisTemplate.opsForZSet()<br \/>\n                .rangeWithScores(RedisConstants.LIKES_ACCESS_STRATEGY_KEY, 0, removeCount &#8211; 1);<\/p>\n<p>        if (CollUtils.isEmpty(tuples)) {<br \/>\n            return;<br \/>\n        }<\/p>\n<p>        for (ZSetOperations.TypedTuple&lt;String&gt; tuple : tuples) {<br \/>\n            String bizIdStr &#061; tuple.getValue();<br \/>\n            Long bizId &#061; Long.valueOf(bizIdStr);<\/p>\n<p>            \/\/ 3.\u83b7\u53d6Redis\u4e2d\u7684\u6570\u636e<br \/>\n            Set&lt;String&gt; userIdsInRedis &#061; redisTemplate.opsForSet().members(RedisConstants.LIKE_BIZ_KEY_PREFIX &#043; bizIdStr);<br \/>\n            if (userIdsInRedis &#061;&#061; null) {<br \/>\n                userIdsInRedis &#061; new HashSet&lt;&gt;();<br \/>\n            }<\/p>\n<p>            \/\/ 4.\u83b7\u53d6DB\u4e2d\u7684\u6570\u636e<br \/>\n            List&lt;LikedRecord&gt; dbRecords &#061; lambdaQuery().eq(LikedRecord::getBizId, bizId).list();<br \/>\n            Set&lt;String&gt; userIdsInDb &#061; dbRecords.stream().map(r -&gt; r.getUserId().toString()).collect(Collectors.toSet());<\/p>\n<p>            \/\/ 5.\u8ba1\u7b97\u5dee\u5f02<br \/>\n            Set&lt;String&gt; toAdd &#061; new HashSet&lt;&gt;(userIdsInRedis);<br \/>\n            toAdd.removeAll(userIdsInDb);<\/p>\n<p>            Set&lt;String&gt; toDelete &#061; new HashSet&lt;&gt;(userIdsInDb);<br \/>\n            toDelete.removeAll(userIdsInRedis);<\/p>\n<p>            \/\/ 6.\u540c\u6b65\u5230DB<br \/>\n            if (!toAdd.isEmpty()) {<br \/>\n                \/\/ \u83b7\u53d6bizType<br \/>\n                Object bizTypeObj &#061; redisTemplate.opsForHash().get(RedisConstants.LIKES_BIZ_TYPE_MAP_KEY, bizIdStr);<br \/>\n                String bizType &#061; (bizTypeObj !&#061; null) ? bizTypeObj.toString() :<br \/>\n                        (!dbRecords.isEmpty() ? dbRecords.get(0).getBizType() : &#034;UNKNOWN&#034;);<\/p>\n<p>                List&lt;LikedRecord&gt; newRecords &#061; toAdd.stream().map(uid -&gt; {<br \/>\n                    LikedRecord r &#061; new LikedRecord();<br \/>\n                    r.setBizId(bizId);<br \/>\n                    r.setUserId(Long.valueOf(uid));<br \/>\n                    r.setBizType(bizType);<br \/>\n                    return r;<br \/>\n                }).collect(Collectors.toList());<br \/>\n                saveBatch(newRecords);<br \/>\n            }<\/p>\n<p>            if (!toDelete.isEmpty()) {<br \/>\n                List&lt;Long&gt; userIdsToDelete &#061; toDelete.stream().map(Long::valueOf).collect(Collectors.toList());<br \/>\n                lambdaUpdate().eq(LikedRecord::getBizId, bizId).in(LikedRecord::getUserId, userIdsToDelete).remove();<br \/>\n            }<\/p>\n<p>            \/\/ 7.\u6e05\u7406Redis<br \/>\n            redisTemplate.delete(RedisConstants.LIKE_BIZ_KEY_PREFIX &#043; bizIdStr);<br \/>\n            redisTemplate.opsForHash().delete(RedisConstants.LIKES_BIZ_TYPE_MAP_KEY, bizIdStr);<br \/>\n            redisTemplate.opsForZSet().remove(RedisConstants.LIKES_ACCESS_STRATEGY_KEY, bizIdStr);<br \/>\n        }<br \/>\n    }<\/p>\n<p>    &#064;Override<br \/>\n    public void readLikedTimesAndSendMessage(String bizType, int maxBizSize) {<br \/>\n        \/\/ 1.\u8bfb\u53d6\u5e76\u79fb\u9664Redis\u4e2d\u7f13\u5b58\u7684\u70b9\u8d5e\u603b\u6570<br \/>\n        String key &#061; RedisConstants.LIKES_TIMES_KEY_PREFIX &#043; bizType;<br \/>\n        Set&lt;ZSetOperations.TypedTuple&lt;String&gt;&gt; tuples &#061; redisTemplate.opsForZSet().popMin(key, maxBizSize);<br \/>\n        if (CollUtils.isEmpty(tuples)) {<br \/>\n            return;<br \/>\n        }<br \/>\n        \/\/ 2.\u6570\u636e\u8f6c\u6362<br \/>\n        List&lt;LikedTimesDTO&gt; list &#061; new ArrayList&lt;&gt;(tuples.size());<br \/>\n        for (ZSetOperations.TypedTuple&lt;String&gt; tuple : tuples) {<br \/>\n            String bizId &#061; tuple.getValue();<br \/>\n            Double likedTimes &#061; tuple.getScore();<br \/>\n            if (bizId &#061;&#061; null || likedTimes &#061;&#061; null) {<br \/>\n                continue;<br \/>\n            }<br \/>\n            list.add(new LikedTimesDTO(Long.valueOf(bizId), likedTimes.intValue()));<br \/>\n        }<br \/>\n        \/\/ 3.\u53d1\u9001MQ\u6d88\u606f<br \/>\n        mqHelper.send(<br \/>\n                LIKE_RECORD_EXCHANGE,<br \/>\n                StringUtils.format(LIKED_TIMES_KEY_TEMPLATE, bizType),<br \/>\n                list);<br \/>\n    }<\/p>\n<p>    private boolean unlike(LikeRecordFormDTO recordDTO) {<br \/>\n        \/\/ 1.\u83b7\u53d6\u7528\u6237id<br \/>\n        Long userId &#061; UserContext.getUser();<br \/>\n        \/\/ 2.\u83b7\u53d6Key<br \/>\n        String key &#061; RedisConstants.LIKE_BIZ_KEY_PREFIX &#043; recordDTO.getBizId();<br \/>\n        \/\/ 3.\u6267\u884cSREM\u547d\u4ee4<br \/>\n        Long result &#061; redisTemplate.opsForSet().remove(key, userId.toString());<br \/>\n        return result !&#061; null &amp;&amp; result &gt; 0;<br \/>\n    }<\/p>\n<p>    private boolean like(LikeRecordFormDTO recordDTO) {<br \/>\n        \/\/ 1.\u83b7\u53d6\u7528\u6237id<br \/>\n        Long userId &#061; UserContext.getUser();<br \/>\n        \/\/ 2.\u83b7\u53d6Key<br \/>\n        String key &#061; RedisConstants.LIKE_BIZ_KEY_PREFIX &#043; recordDTO.getBizId();<br \/>\n        \/\/ 3.\u6267\u884cSADD\u547d\u4ee4<br \/>\n        Long result &#061; redisTemplate.opsForSet().add(key, userId.toString());<br \/>\n        return result !&#061; null &amp;&amp; result &gt; 0;<br \/>\n    }<br \/>\n}<br \/>\npackage com.tianji.remark.constants;<\/p>\n<p>public interface RedisConstants {<br \/>\n    \/*\u7ed9\u4e1a\u52a1\u70b9\u8d5e\u7684\u7528\u6237\u96c6\u5408\u7684KEY\u524d\u7f00&#xff0c;\u540e\u7f00\u662f\u4e1a\u52a1id*\/<br \/>\n    String LIKE_BIZ_KEY_PREFIX &#061; &#034;likes:set:biz:&#034;;<br \/>\n    \/*\u4e1a\u52a1\u70b9\u8d5e\u6570\u7edf\u8ba1\u7684KEY\u524d\u7f00&#xff0c;\u540e\u7f00\u662f\u4e1a\u52a1\u7c7b\u578b*\/<br \/>\n    String LIKES_TIMES_KEY_PREFIX &#061; &#034;likes:times:type:&#034;;<br \/>\n    \/*\u4e1a\u52a1\u70b9\u8d5e\u4e1a\u52a1\u7c7b\u578b\u6620\u5c04*\/<br \/>\n    String LIKES_BIZ_TYPE_MAP_KEY &#061; &#034;likes:biz:type&#034;;<br \/>\n    \/*\u4e1a\u52a1\u70b9\u8d5e\u8bbf\u95ee\u7b56\u7565\u96c6\u5408&#xff08;\u7528\u4e8eLFU\/LRU&#xff09;*\/<br \/>\n    String LIKES_ACCESS_STRATEGY_KEY &#061; &#034;likes:access:strategy&#034;;<br \/>\n}<br \/>\npackage com.tianji.remark.task;<\/p>\n<p>import com.tianji.remark.service.ILikedRecordService;<br \/>\nimport lombok.RequiredArgsConstructor;<br \/>\nimport lombok.extern.slf4j.Slf4j;<br \/>\nimport org.springframework.beans.factory.annotation.Value;<br \/>\nimport org.springframework.cloud.context.config.annotation.RefreshScope;<br \/>\nimport org.springframework.scheduling.annotation.Scheduled;<br \/>\nimport org.springframework.stereotype.Component;<\/p>\n<p>import java.util.List;<\/p>\n<p>&#064;Slf4j<br \/>\n&#064;Component<br \/>\n&#064;RequiredArgsConstructor<br \/>\n&#064;RefreshScope \/\/ \u652f\u6301Nacos\u52a8\u6001\u5237\u65b0\u914d\u7f6e<br \/>\npublic class LikedTimesCheckTask {<\/p>\n<p>    &#064;Value(&#034;${tj.remark.task.biz-types:QA,NOTE}&#034;)<br \/>\n    private List&lt;String&gt; bizTypes;<\/p>\n<p>    &#064;Value(&#034;${tj.remark.task.max-biz-size:30}&#034;)<br \/>\n    private int maxBizSize;<\/p>\n<p>    private final ILikedRecordService recordService;<\/p>\n<p>    &#064;Scheduled(fixedDelay &#061; 2000)<br \/>\n    public void checkLikedTimes(){<br \/>\n        for (String bizType : bizTypes) {<br \/>\n            recordService.readLikedTimesAndSendMessage(bizType, maxBizSize);<br \/>\n        }<br \/>\n    }<\/p>\n<p>    &#064;Scheduled(fixedDelay &#061; 10000)<br \/>\n    public void checkOldRecords(){<br \/>\n        int maxCapacity &#061; 10000;<br \/>\n        recordService.persistOldRecords(maxCapacity);<br \/>\n    }<br \/>\n} <\/p>\n<\/p>\n<\/p>\n<p><span style=\"color:#fe2c24\">\u611f\u5174\u8da3\u7684\u5b9d\u5b50\u53ef\u4ee5\u5173\u6ce8\u4e00\u6ce2&#xff0c;\u540e\u7eed\u4f1a\u66f4\u65b0\u66f4\u591a\u6709\u7528\u7684\u77e5\u8bc6&#xff01;&#xff01;&#xff01;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"709\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260128143255-697a1e171475b.png\" width=\"1192\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u5f55<br \/>\n1.\u539f\u59cb\u7684\u70b9\u8d5e\u4e1a\u52a1<br \/>\n1.1\u9875\u9762\u539f\u578b<br \/>\n1.2\u70b9\u8d5e\u4e1a\u52a1<br \/>\n1.2.1\u6570\u636e\u5e93\u8868<br \/>\n1.2.2\u4e1a\u52a1\u6d41\u7a0b<br \/>\n1.2.3\u4e1a\u52a1\u4ee3\u7801<br \/>\n1.3 \u539f\u59cb\u65b9\u6848\u7684\u6027\u80fd\u74f6\u9888<br \/>\n2.\u9ad8\u5e76\u53d1\u4f18\u5316\u601d\u8def&#xff1a;Redis  \u5408\u5e76\u5199\u8bf7\u6c42<br \/>\n2.1 \u4f18\u5316\u65b9\u5411\u5206\u6790<br \/>\n2.2\u4fee\u6539\u4e4b\u540e\u7684\u4e1a\u52a1\u5206\u6790<br \/>\n2.2.1\u6838\u5fc3\u4e1a\u52a1\u6d41\u7a0b<br \/>\n2.2.2Redis \u6570\u636e\u7ed3\u6784\u9009\u578b<br \/>\n2.3\u4ee3\u7801\u5b9e\u73b0<br \/>\n2.3.1\u4ee3\u7801\u5b9e\u73b0\u6d41\u7a0b\u56fe<br \/>\n2.3.2\u6838\u5fc3\u63a5\u53e3\u6539\u9020&#xff08;\u70b9\u8d5e \/ \u53d6\u6d88&#xff09;<br \/>\n2.3.3Pipeli<\/p>\n","protected":false},"author":2,"featured_media":67542,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[98,963,100],"topic":[],"class_list":["post-67552","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-spring-boot","tag-spring-cloud","tag-100"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u5929\u673a\u5b66\u5802\u2014\u2014\u70b9\u8d5e\u529f\u80fd - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/67552.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u5929\u673a\u5b66\u5802\u2014\u2014\u70b9\u8d5e\u529f\u80fd - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u76ee\u5f55 1.\u539f\u59cb\u7684\u70b9\u8d5e\u4e1a\u52a1 1.1\u9875\u9762\u539f\u578b 1.2\u70b9\u8d5e\u4e1a\u52a1 1.2.1\u6570\u636e\u5e93\u8868 1.2.2\u4e1a\u52a1\u6d41\u7a0b 1.2.3\u4e1a\u52a1\u4ee3\u7801 1.3 \u539f\u59cb\u65b9\u6848\u7684\u6027\u80fd\u74f6\u9888 2.\u9ad8\u5e76\u53d1\u4f18\u5316\u601d\u8def&#xff1a;Redis \u5408\u5e76\u5199\u8bf7\u6c42 2.1 \u4f18\u5316\u65b9\u5411\u5206\u6790 2.2\u4fee\u6539\u4e4b\u540e\u7684\u4e1a\u52a1\u5206\u6790 2.2.1\u6838\u5fc3\u4e1a\u52a1\u6d41\u7a0b 2.2.2Redis \u6570\u636e\u7ed3\u6784\u9009\u578b 2.3\u4ee3\u7801\u5b9e\u73b0 2.3.1\u4ee3\u7801\u5b9e\u73b0\u6d41\u7a0b\u56fe 2.3.2\u6838\u5fc3\u63a5\u53e3\u6539\u9020&#xff08;\u70b9\u8d5e \/ \u53d6\u6d88&#xff09; 2.3.3Pipeli\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/67552.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-01-28T14:32:56+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260128143253-697a1e153a338.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"12 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/67552.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/67552.html\",\"name\":\"\u5929\u673a\u5b66\u5802\u2014\u2014\u70b9\u8d5e\u529f\u80fd - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-01-28T14:32:56+00:00\",\"dateModified\":\"2026-01-28T14:32:56+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/67552.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/67552.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/67552.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u5929\u673a\u5b66\u5802\u2014\u2014\u70b9\u8d5e\u529f\u80fd\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u5929\u673a\u5b66\u5802\u2014\u2014\u70b9\u8d5e\u529f\u80fd - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/67552.html","og_locale":"zh_CN","og_type":"article","og_title":"\u5929\u673a\u5b66\u5802\u2014\u2014\u70b9\u8d5e\u529f\u80fd - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u76ee\u5f55 1.\u539f\u59cb\u7684\u70b9\u8d5e\u4e1a\u52a1 1.1\u9875\u9762\u539f\u578b 1.2\u70b9\u8d5e\u4e1a\u52a1 1.2.1\u6570\u636e\u5e93\u8868 1.2.2\u4e1a\u52a1\u6d41\u7a0b 1.2.3\u4e1a\u52a1\u4ee3\u7801 1.3 \u539f\u59cb\u65b9\u6848\u7684\u6027\u80fd\u74f6\u9888 2.\u9ad8\u5e76\u53d1\u4f18\u5316\u601d\u8def&#xff1a;Redis \u5408\u5e76\u5199\u8bf7\u6c42 2.1 \u4f18\u5316\u65b9\u5411\u5206\u6790 2.2\u4fee\u6539\u4e4b\u540e\u7684\u4e1a\u52a1\u5206\u6790 2.2.1\u6838\u5fc3\u4e1a\u52a1\u6d41\u7a0b 2.2.2Redis \u6570\u636e\u7ed3\u6784\u9009\u578b 2.3\u4ee3\u7801\u5b9e\u73b0 2.3.1\u4ee3\u7801\u5b9e\u73b0\u6d41\u7a0b\u56fe 2.3.2\u6838\u5fc3\u63a5\u53e3\u6539\u9020&#xff08;\u70b9\u8d5e \/ \u53d6\u6d88&#xff09; 2.3.3Pipeli","og_url":"https:\/\/www.wsisp.com\/helps\/67552.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-01-28T14:32:56+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260128143253-697a1e153a338.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"12 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/67552.html","url":"https:\/\/www.wsisp.com\/helps\/67552.html","name":"\u5929\u673a\u5b66\u5802\u2014\u2014\u70b9\u8d5e\u529f\u80fd - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-01-28T14:32:56+00:00","dateModified":"2026-01-28T14:32:56+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/67552.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/67552.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/67552.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u5929\u673a\u5b66\u5802\u2014\u2014\u70b9\u8d5e\u529f\u80fd"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/67552","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=67552"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/67552\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/67542"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=67552"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=67552"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=67552"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=67552"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}