{"id":44502,"date":"2024-12-01T15:47:33","date_gmt":"2024-12-01T07:47:33","guid":{"rendered":"https:\/\/fwq.ai\/blog\/44502\/"},"modified":"2024-12-01T15:47:33","modified_gmt":"2024-12-01T07:47:33","slug":"%e5%be%ae%e6%9c%8d%e5%8a%a1springboot%e6%95%b4%e5%90%88redis%e5%ae%9e%e7%8e%b0%e5%a5%bd%e5%8f%8b%e5%85%b3%e6%b3%a8%e5%8a%9f%e8%83%bd","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/44502\/","title":{"rendered":"\u5fae\u670d\u52a1SpringBoot\u6574\u5408Redis\u5b9e\u73b0\u597d\u53cb\u5173\u6ce8\u529f\u80fd"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>\u5fae\u670d\u52a1SpringBoot\u6574\u5408Redis\u5b9e\u73b0\u597d\u53cb\u5173\u6ce8\u529f\u80fd<\/h1>\n<p><span><i><\/i>0\u6d4f\u89c8<\/span><br \/>\n<span style=\"cursor: pointer\"><i><\/i>\u6536\u85cf<\/span> <\/p>\n<p>\u201c\u7eb5\u6709\u75be\u98ce\u6765\uff0c\u4eba\u751f\u4e0d\u8a00\u5f03\u201d\uff0c\u8fd9\u53e5\u8bdd\u9001\u7ed9\u6b63\u5728\u5b66\u4e60<span style=\"color: #FF6600;font-family:\">\u6570\u636e\u5e93<\/span>\u7684\u670b\u53cb\u4eec\uff0c\u4e5f\u5e0c\u671b\u5728\u9605\u8bfb\u672c\u6587<span style=\"color: #FF6600;font-family:\">\u300a\u5fae\u670d\u52a1SpringBoot\u6574\u5408Redis\u5b9e\u73b0\u597d\u53cb\u5173\u6ce8\u529f\u80fd\u300b<\/span>\u540e\uff0c\u80fd\u591f\u771f\u7684\u5e2e\u52a9\u5230\u5927\u5bb6\u3002\u6211\u4e5f\u4f1a\u5728\u540e\u7eed\u7684\u6587\u7ae0\u4e2d\uff0c\u9646\u7eed\u66f4\u65b0<span style=\"color: #FF6600;font-family:\">\u6570\u636e\u5e93<\/span>\u76f8\u5173\u7684\u6280\u672f\u6587\u7ae0\uff0c\u6709\u597d\u7684\u5efa\u8bae\u6b22\u8fce\u5927\u5bb6\u5728\u8bc4\u8bba\u7559\u8a00\uff0c\u975e\u5e38\u611f\u8c22\uff01<\/p>\n<h2>\u5f15\u8a00<\/h2>\n<p><strong>\u672c\u535a\u6587\u53c2\u8003 \u9ed1\u9a6c \u7a0b\u5e8f\u5458B\u7ad9 Redis\u8bfe\u7a0b\u7cfb\u5217<\/strong><\/p>\n<p>\u5728\u70b9\u8bc4\u9879\u76ee\u4e2d\uff0c\u6709\u8fd9\u6837\u7684\u9700\u6c42\uff0c\u5982\u4f55\u5b9e\u73b0\u7b14\u8bb0\u7684<strong>\u597d\u53cb\u5173\u6ce8\u3001\u4ee5\u53ca\u53d1\u5e03\u7b14\u8bb0\u540e\u63a8\u9001\u6d88\u606f<\/strong>\u529f\u80fd\uff1f<\/p>\n<blockquote>\n<p>\u4f7f\u7528Redis \u7684 <strong>\u597d\u53cb\u5173\u6ce8\u3001\u4ee5\u53ca\u53d1\u5e03\u7b14\u8bb0\u540e\u63a8\u9001\u6d88\u606f\u529f\u80fd<\/strong><\/p>\n<\/blockquote>\n<h2>\u4e00\u3001Redis \u5b9e\u73b0\u597d\u53cb\u5173\u6ce8 \u2013 \u5173\u6ce8\u4e0e\u53d6\u6d88\u5173\u6ce8<\/h2>\n<p>\u9700\u6c42\uff1a<strong>\u9488\u5bf9\u7528\u6237\u7684\u64cd\u4f5c\uff0c\u53ef\u4ee5\u5bf9\u7528\u6237\u8fdb\u884c\u5173\u6ce8\u548c\u53d6\u6d88\u5173\u6ce8\u529f\u80fd\u3002<\/strong><\/p>\n<p>\u5728\u63a2\u5e97\u56fe\u6587\u7684\u8be6\u60c5\u9875\u9762\u4e2d\uff0c\u53ef\u4ee5\u5173\u6ce8\u53d1\u5e03\u7b14\u8bb0\u7684\u4f5c\u8005<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20230225\/167729045363f96bd594972.jpg\" class=\"aligncenter\" title=\"\u5fae\u670d\u52a1SpringBoot\u6574\u5408Redis\u5b9e\u73b0\u597d\u53cb\u5173\u6ce8\u529f\u80fd\u63d2\u56fe\" alt=\"\u5fae\u670d\u52a1SpringBoot\u6574\u5408Redis\u5b9e\u73b0\u597d\u53cb\u5173\u6ce8\u529f\u80fd\u63d2\u56fe\" \/><\/p>\n<p>\u5177\u4f53\u5b9e\u73b0\u601d\u8def\uff1a\u57fa\u4e8e\u8be5\u8868\u6570\u636e\u7ed3\u6784\uff0c\u5b9e\u73b02\u4e2a\u63a5\u53e3<\/p>\n<ul>\n<li>\u5173\u6ce8\u548c\u53d6\u5173\u63a5\u53e3<\/li>\n<li>\u5224\u65ad\u662f\u5426\u5173\u6ce8\u7684\u63a5\u53e3<\/li>\n<\/ul>\n<p>\u5173\u6ce8\u662f\u7528\u6237\u4e4b\u95f4\u7684\u5173\u7cfb\uff0c\u662f\u535a\u4e3b\u4e0e\u7c89\u4e1d\u7684\u5173\u7cfb\uff0c\u6570\u636e\u8868\u5982\u4e0b\uff1a<\/p>\n<p><strong>tb_follow<\/strong><\/p>\n<pre>CREATE TABLE `tb_follow` (\n  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '\u4e3b\u952e',\n  `user_id` bigint(20) unsigned NOT NULL COMMENT '\u7528\u6237id',\n  `follow_user_id` bigint(20) unsigned NOT NULL COMMENT '\u5173\u8054\u7684\u7528\u6237id',\n  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '\u521b\u5efa\u65f6\u95f4',\n  PRIMARY KEY (`id`) USING BTREE\n) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT;<\/pre>\n<p><strong>id\u4e3a\u81ea\u589e\u957f\uff0c\u7b80\u5316\u5f00\u53d1<\/strong><\/p>\n<blockquote>\n<p><strong>\u6838\u5fc3\u4ee3\u7801<\/strong><\/p>\n<\/blockquote>\n<p><strong>FollowController<\/strong><\/p>\n<pre>\/\/\u5173\u6ce8\n@PutMapping(\"\/{id}\/{isFollow}\")\npublic Result follow(@PathVariable(\"id\") Long followUserId, @PathVariable(\"isFollow\") Boolean isFollow) {\n    return followService.follow(followUserId, isFollow);\n}\n\/\/\u53d6\u6d88\u5173\u6ce8\n@GetMapping(\"\/or\/not\/{id}\")\npublic Result isFollow(@PathVariable(\"id\") Long followUserId) {\n    return followService.isFollow(followUserId);\n}<\/pre>\n<p><strong>FollowService<\/strong><\/p>\n<pre>@Override\npublic Result follow(Long followUserId, Boolean isFollow) {\n    \/\/ 1.\u83b7\u53d6\u767b\u5f55\u7528\u6237\n    Long userId = UserHolder.getUser().getId();\n    String key = \"follows:\" + userId;\n    \/\/ 1.\u5224\u65ad\u5230\u5e95\u662f\u5173\u6ce8\u8fd8\u662f\u53d6\u5173\n    if (isFollow) {\n        \/\/ 2.\u5173\u6ce8\uff0c\u65b0\u589e\u6570\u636e\n        Follow follow = new Follow();\n        follow.setUserId(userId);\n        follow.setFollowUserId(followUserId);\n        boolean isSuccess = save(follow);\n        if (isSuccess) {\n            stringRedisTemplate.opsForSet().add(key, followUserId.toString());\n        }\n    } else {\n        \/\/ 3.\u53d6\u5173\uff0c\u5220\u9664 delete from tb_follow where user_id = ? and follow_user_id = ?\n        boolean isSuccess = remove(new QueryWrapper\n   \n    ()\n                                   .eq(\"user_id\", userId).eq(\"follow_user_id\", followUserId));\n        if (isSuccess) {\n            \/\/ \u628a\u5173\u6ce8\u7528\u6237\u7684id\u4eceRedis\u96c6\u5408\u4e2d\u79fb\u9664\n            stringRedisTemplate.opsForSet().remove(key, followUserId.toString());\n        }\n    }\n    return Result.ok();\n}\n\n@Override\npublic Result isFollow(Long followUserId) {\n    \/\/ 1.\u83b7\u53d6\u767b\u5f55\u7528\u6237\n    Long userId = UserHolder.getUser().getId();\n    \/\/ 2.\u67e5\u8be2\u662f\u5426\u5173\u6ce8 select count(*) from tb_follow where user_id = ? and follow_user_id = ?\n    Integer count = query().eq(\"user_id\", userId).eq(\"follow_user_id\", followUserId).count();\n    \/\/ 3.\u5224\u65ad\n    return Result.ok(count &gt; 0);\n}\n\n\n   <\/pre>\n<p><strong>\u4ee3\u7801\u7f16\u5199\u5b8c\u6bd5\uff0c\u8fdb\u884c\u6d4b\u8bd5<\/strong><\/p>\n<blockquote>\n<p><strong>\u4ee3\u7801\u6d4b\u8bd5<\/strong><\/p>\n<\/blockquote>\n<p><strong>\u70b9\u51fb\u8fdb\u884c\u5173\u6ce8\u7528\u6237<\/strong><\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20230225\/167729045363f96bd5e98e6.jpg\" class=\"aligncenter\" title=\"\u5fae\u670d\u52a1SpringBoot\u6574\u5408Redis\u5b9e\u73b0\u597d\u53cb\u5173\u6ce8\u529f\u80fd\u63d2\u56fe1\" alt=\"\u5fae\u670d\u52a1SpringBoot\u6574\u5408Redis\u5b9e\u73b0\u597d\u53cb\u5173\u6ce8\u529f\u80fd\u63d2\u56fe1\" \/><\/p>\n<p><strong>\u5173\u6ce8\u6210\u529f<\/strong><\/p>\n<p><strong>\u53d6\u6d88\u5173\u6ce8<\/strong><\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20230225\/167729045463f96bd6559c0.jpg\" class=\"aligncenter\" title=\"\u5fae\u670d\u52a1SpringBoot\u6574\u5408Redis\u5b9e\u73b0\u597d\u53cb\u5173\u6ce8\u529f\u80fd\u63d2\u56fe2\" alt=\"\u5fae\u670d\u52a1SpringBoot\u6574\u5408Redis\u5b9e\u73b0\u597d\u53cb\u5173\u6ce8\u529f\u80fd\u63d2\u56fe2\" \/><\/p>\n<p><strong>\u6d4b\u8bd5\u6210\u529f<\/strong><\/p>\n<h2>\u4e8c\u3001Redis \u5b9e\u73b0\u597d\u53cb\u5173\u6ce8 \u2013 \u5171\u540c\u5173\u6ce8\u529f\u80fd<\/h2>\n<p>\u5b9e\u73b0\u5171\u540c\u5173\u6ce8\u597d\u53cb\u529f\u80fd\uff0c\u9996\u5148\uff0c\u9700\u8981\u8fdb\u5165\u535a\u4e3b\u53d1\u5e03\u7684\u6307\u5b9a\u7b14\u8bb0\u9875\uff0c\u7136\u540e\u70b9\u51fb\u535a\u4e3b\u7684\u5934\u50cf\u53bb\u67e5\u770b\u8be6\u7ec6\u4fe1\u606f<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20230225\/167729045463f96bd6b52a4.jpg\" class=\"aligncenter\" title=\"\u5fae\u670d\u52a1SpringBoot\u6574\u5408Redis\u5b9e\u73b0\u597d\u53cb\u5173\u6ce8\u529f\u80fd\u63d2\u56fe3\" alt=\"\u5fae\u670d\u52a1SpringBoot\u6574\u5408Redis\u5b9e\u73b0\u597d\u53cb\u5173\u6ce8\u529f\u80fd\u63d2\u56fe3\" \/><\/p>\n<p><strong>\u6838\u5fc3\u4ee3\u7801\u5982\u4e0b<\/strong><\/p>\n<p><strong>UserController<\/strong><\/p>\n<pre>\/\/ UserController \u6839\u636eid\u67e5\u8be2\u7528\u6237\n@GetMapping(\"\/{id}\")\npublic Result queryUserById(@PathVariable(\"id\") Long userId){\n    \/\/ \u67e5\u8be2\u8be6\u60c5\n    User user = userService.getById(userId);\n    if (user == null) {\n        return Result.ok();\n    }\n    UserDTO userDTO = BeanUtil.copyProperties(user, UserDTO.class);\n    \/\/ \u8fd4\u56de\n    return Result.ok(userDTO);\n}\n\n<\/pre>\n<p><strong>BlogController<\/strong><\/p>\n<pre>@GetMapping(\"\/of\/user\")\npublic Result queryBlogByUserId(\n    @RequestParam(value = \"current\", defaultValue = \"1\") Integer current,\n    @RequestParam(\"id\") Long id) {\n    \/\/ \u6839\u636e\u7528\u6237\u67e5\u8be2\n    Page\n   \n     page = blogService.query()\n        .eq(\"user_id\", id).page(new Page(current, SystemConstants.MAX_PAGE_SIZE));\n    \/\/ \u83b7\u53d6\u5f53\u524d\u9875\u6570\u636e\n    List\n    \n      records = page.getRecords(); return Result.ok(records); }\n    \n   <\/pre>\n<p><strong>\u90a3\u4e48\u5982\u4f55\u5b9e\u73b0\u5171\u540c\u597d\u53cb\u5173\u6ce8\u529f\u80fd\u5462\uff1f<\/strong><\/p>\n<p>\u9700\u6c42\uff1a\u5229\u7528Redis\u4e2d\u7684\u6570\u636e\u7ed3\u6784\uff0c\u5b9e\u73b0\u5171\u540c\u5173\u6ce8\u529f\u80fd\u3002 \u5728\u535a\u4e3b\u4e2a\u4eba\u9875\u9762\u5c55\u793a\u51fa\u5f53\u524d\u7528\u6237\u4e0e\u535a\u4e3b\u7684\u5171\u540c\u5173\u6ce8<\/p>\n<p><strong>\u601d\u8def\u5206\u6790\uff1a<\/strong> \u4f7f\u7528Redis\u7684Set\u96c6\u5408\u5b9e\u73b0\uff0c\u6211\u4eec\u628a\u4e24\u4eba\u5173\u6ce8\u7684\u4eba\u5206\u522b\u653e\u5165\u5230\u4e00\u4e2aSet\u96c6\u5408\u4e2d\uff0c\u7136\u540e\u518d\u901a\u8fc7API\u53bb\u67e5\u770b\u4e24\u4e2aSet\u96c6\u5408\u4e2d\u7684\u4ea4\u96c6\u6570\u636e<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20230225\/167729045563f96bd72a11f.png\" class=\"aligncenter\" title=\"\u5fae\u670d\u52a1SpringBoot\u6574\u5408Redis\u5b9e\u73b0\u597d\u53cb\u5173\u6ce8\u529f\u80fd\u63d2\u56fe4\" alt=\"\u5fae\u670d\u52a1SpringBoot\u6574\u5408Redis\u5b9e\u73b0\u597d\u53cb\u5173\u6ce8\u529f\u80fd\u63d2\u56fe4\" \/><\/p>\n<p><strong>\u6539\u9020\u6838\u5fc3\u4ee3\u7801<\/strong>\uff1a<\/p>\n<p>\u5f53\u7528\u6237\u5173\u6ce8\u67d0\u4f4d\u7528\u6237\u540e\uff0c\u9700\u8981\u5c06\u6570\u636e\u5b58\u5165Redis\u96c6\u5408\u4e2d\uff0c\u65b9\u4fbf\u540e\u7eed\u8fdb\u884c\u5171\u540c\u5173\u6ce8\u7684\u5b9e\u73b0\uff0c\u540c\u65f6\u53d6\u6d88\u5173\u6ce8\u65f6\uff0c\u9700\u8981\u5220\u9664Redis\u4e2d\u7684\u96c6\u5408<\/p>\n<p><strong>FlowServiceImpl<\/strong><\/p>\n<pre>@Override\npublic Result follow(Long followUserId, Boolean isFollow) {\n    \/\/ 1.\u83b7\u53d6\u767b\u5f55\u7528\u6237\n    Long userId = UserHolder.getUser().getId();\n    String key = \"follows:\" + userId;\n    \/\/ 1.\u5224\u65ad\u5230\u5e95\u662f\u5173\u6ce8\u8fd8\u662f\u53d6\u5173\n    if (isFollow) {\n        \/\/ 2.\u5173\u6ce8\uff0c\u65b0\u589e\u6570\u636e\n        Follow follow = new Follow();\n        follow.setUserId(userId);\n        follow.setFollowUserId(followUserId);\n        boolean isSuccess = save(follow);\n        if (isSuccess) {\n            stringRedisTemplate.opsForSet().add(key, followUserId.toString());\n        }\n    } else {\n        \/\/ 3.\u53d6\u5173\uff0c\u5220\u9664 delete from tb_follow where user_id = ? and follow_user_id = ?\n        boolean isSuccess = remove(new QueryWrapper\n   \n    ()\n                                   .eq(\"user_id\", userId).eq(\"follow_user_id\", followUserId));\n        if (isSuccess) {\n            \/\/ \u628a\u5173\u6ce8\u7528\u6237\u7684id\u4eceRedis\u96c6\u5408\u4e2d\u79fb\u9664\n            stringRedisTemplate.opsForSet().remove(key, followUserId.toString());\n        }\n    }\n    return Result.ok();\n}\n\n\/\/ \u5177\u4f53\u83b7\u53d6\u597d\u53cb\u5171\u540c\u5173\u6ce8\u4ee3\u7801\n\n@Override\npublic Result followCommons(Long id) {\n    \/\/ 1.\u83b7\u53d6\u5f53\u524d\u7528\u6237\n    Long userId = UserHolder.getUser().getId();\n    String key = \"follows:\" + userId;\n    \/\/ 2.\u6c42\u4ea4\u96c6\n    String key2 = \"follows:\" + id;\n    Set\n    \n      intersect = stringRedisTemplate.opsForSet().intersect(key, key2); if (intersect == null || intersect.isEmpty()) { \/\/ \u65e0\u4ea4\u96c6 return Result.ok(Collections.emptyList()); } \/\/ 3.\u89e3\u6790id\u96c6\u5408 List\n     \n       ids = intersect.stream().map(Long::valueOf).collect(Collectors.toList()); \/\/ 4.\u67e5\u8be2\u7528\u6237 List\n      \n        users = userService.listByIds(ids) .stream() .map(user -&gt; BeanUtil.copyProperties(user, UserDTO.class)) .collect(Collectors.toList()); return Result.ok(users); } \n      \n     \n    \n   <\/pre>\n<p><strong>\u8fdb\u884c\u6d4b\u8bd5<\/strong><\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20230225\/167729045563f96bd77e014.png\" class=\"aligncenter\" title=\"\u5fae\u670d\u52a1SpringBoot\u6574\u5408Redis\u5b9e\u73b0\u597d\u53cb\u5173\u6ce8\u529f\u80fd\u63d2\u56fe5\" alt=\"\u5fae\u670d\u52a1SpringBoot\u6574\u5408Redis\u5b9e\u73b0\u597d\u53cb\u5173\u6ce8\u529f\u80fd\u63d2\u56fe5\" \/><\/p>\n<h2>\u5c0f\u7ed3<\/h2>\n<p>\u597d\u4e86\uff0c\u672c\u6587\u5230\u6b64\u7ed3\u675f\uff0c\u5e26\u5927\u5bb6\u4e86\u89e3\u4e86\u300a\u5fae\u670d\u52a1SpringBoot\u6574\u5408Redis\u5b9e\u73b0\u597d\u53cb\u5173\u6ce8\u529f\u80fd\u300b\uff0c\u5e0c\u671b\u672c\u6587\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff01\u5173\u6ce8golang\u5b66\u4e60\u7f51\u516c\u4f17\u53f7\uff0c\u7ed9\u5927\u5bb6\u5206\u4eab\u66f4\u591a\u6570\u636e\u5e93\u77e5\u8bc6\uff01<\/p>\n<p>     \u7248\u672c\u58f0\u660e \u672c\u6587\u8f6c\u8f7d\u4e8e\uff1a\u811a\u672c\u4e4b\u5bb6 \u5982\u6709\u4fb5\u72af\uff0c\u8bf7\u8054\u7cfb \u5220\u9664  <\/p>\n<dl>\n<dt>\n <\/dt>\n<dd>\n   redis\u6a21\u7cca\u6279\u91cf\u5220\u9664key\u7684\u65b9\u6cd5\n <\/dd>\n<\/dl>\n<dl>\n<dt>\n <\/dt>\n<dd>\n   Redis\u4e2dBloomfilter\u5e03\u9686\u8fc7\u6ee4\u5668\u7684\u5b66\u4e60\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>\u5fae\u670d\u52a1SpringBoot\u6574\u5408Redis\u5b9e\u73b0\u597d\u53cb\u5173\u6ce8\u529f\u80fd 0\u6d4f\u89c8 \u6536\u85cf \u201c\u7eb5\u6709\u75be\u98ce\u6765\uff0c\u4eba\u751f\u4e0d\u8a00\u5f03\u201d\uff0c\u8fd9\u53e5\u8bdd\u9001\u7ed9\u6b63\u5728\u5b66\u4e60\u6570\u636e\u5e93\u7684\u670b\u53cb\u4eec\uff0c\u4e5f\u5e0c\u671b\u5728\u9605\u8bfb\u672c\u6587\u300a\u5fae\u670d\u52a1SpringBoot\u6574\u5408Redis\u5b9e\u73b0\u597d\u53cb\u5173\u6ce8\u529f\u80fd\u300b\u540e\uff0c\u80fd\u591f\u771f\u7684\u5e2e\u52a9\u5230\u5927\u5bb6\u3002\u6211\u4e5f\u4f1a\u5728\u540e\u7eed\u7684\u6587\u7ae0\u4e2d\uff0c\u9646\u7eed\u66f4\u65b0\u6570\u636e\u5e93\u76f8\u5173\u7684\u6280\u672f\u6587\u7ae0\uff0c\u6709\u597d\u7684\u5efa\u8bae\u6b22\u8fce\u5927\u5bb6\u5728\u8bc4\u8bba\u7559\u8a00\uff0c\u975e\u5e38\u611f\u8c22\uff01 \u5f15\u8a00 \u672c\u535a\u6587\u53c2\u8003 \u9ed1\u9a6c \u7a0b\u5e8f\u5458B\u7ad9 Redis\u8bfe\u7a0b\u7cfb\u5217 \u5728\u70b9\u8bc4\u9879\u76ee\u4e2d\uff0c\u6709\u8fd9\u6837\u7684\u9700\u6c42\uff0c\u5982\u4f55\u5b9e\u73b0\u7b14\u8bb0\u7684\u597d\u53cb\u5173\u6ce8\u3001\u4ee5\u53ca\u53d1\u5e03\u7b14\u8bb0\u540e\u63a8\u9001\u6d88\u606f\u529f\u80fd\uff1f \u4f7f\u7528Redis \u7684 \u597d\u53cb\u5173\u6ce8\u3001\u4ee5\u53ca\u53d1\u5e03\u7b14\u8bb0\u540e\u63a8\u9001\u6d88\u606f\u529f\u80fd \u4e00\u3001Redis \u5b9e\u73b0\u597d\u53cb\u5173\u6ce8 \u2013 \u5173\u6ce8\u4e0e\u53d6\u6d88\u5173\u6ce8 \u9700\u6c42\uff1a\u9488\u5bf9\u7528\u6237\u7684\u64cd\u4f5c\uff0c\u53ef\u4ee5\u5bf9\u7528\u6237\u8fdb\u884c\u5173\u6ce8\u548c\u53d6\u6d88\u5173\u6ce8\u529f\u80fd\u3002 \u5728\u63a2\u5e97\u56fe\u6587\u7684\u8be6\u60c5\u9875\u9762\u4e2d\uff0c\u53ef\u4ee5\u5173\u6ce8\u53d1\u5e03\u7b14\u8bb0\u7684\u4f5c\u8005 \u5177\u4f53\u5b9e\u73b0\u601d\u8def\uff1a\u57fa\u4e8e\u8be5\u8868\u6570\u636e\u7ed3\u6784\uff0c\u5b9e\u73b02\u4e2a\u63a5\u53e3 \u5173\u6ce8\u548c\u53d6\u5173\u63a5\u53e3 \u5224\u65ad\u662f\u5426\u5173\u6ce8\u7684\u63a5\u53e3 \u5173\u6ce8\u662f\u7528\u6237\u4e4b\u95f4\u7684\u5173\u7cfb\uff0c\u662f\u535a\u4e3b\u4e0e\u7c89\u4e1d\u7684\u5173\u7cfb\uff0c\u6570\u636e\u8868\u5982\u4e0b\uff1a tb_follow CREATE TABLE `tb_follow` ( `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT &#8216;\u4e3b\u952e&#8217;, `user_id` bigint(20) unsigned NOT NULL COMMENT &#8216;\u7528\u6237id&#8217;, `follow_user_id` bigint(20) unsigned NOT NULL COMMENT &#8216;\u5173\u8054\u7684\u7528\u6237id&#8217;, `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-44502","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/44502","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=44502"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/44502\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=44502"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=44502"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=44502"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}