From 6fadc5e96dbc6735ab41a719c45534af4cd68c0f Mon Sep 17 00:00:00 2001 From: Wonder Date: Fri, 24 Oct 2025 13:01:48 +0800 Subject: [PATCH] Update --- Home.md | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/Home.md b/Home.md index 8023888..f8816a2 100644 --- a/Home.md +++ b/Home.md @@ -68,4 +68,35 @@ CREATE UNIQUE INDEX idx_userId_blogId ON thumb (userId, blogId); > > — _Effective Java Item 18_ - 不建议选择 `Interface` 定义常量 -- 而应该选用 `Class - public static final String` 定义常量 \ No newline at end of file +- 而应该选用 `Class - public static final String` 定义常量 + +--- + +> Q8. *Redis* | 数据键值对是如何设计的? + +使用了 Hash 的数据类型,遵循格式 `Key-Filed-Value`,以下是相关解释 +- Key + - 前缀: "thumb:" + ```java + public static final String USER_THUMB_KEY_PREFIX = "thumb:" + ``` + - 业务键: "{userId}" + - 从会话中获取,对于特定用户映射到同一个 Key +- Filed + - 业务域: "{blogId}" + - 从请求参数中获取,对应具体的用户点赞相关业务的相关博客 +- Value + - 类型: Long + - 内容: 对应数据库中存储的 thumb_id,也就是 thumb 数据表的主键 + +--- + +> Q9. *MybatisPlus* | thumb_id 的获取流程? + +- thumb_id 是 MyBatisPlus 自动生成的 + ```java + @TableId(type = IdType.AUTO) + private Long id; + ``` +- 执行点赞业务时,需要构造 Thumb 对象,补充 userId, blogId,通过 save 方法保存数据库中 +- 处理保存后, MyBatisPlus 会自动回填数据,执行**主键回填**,隐式地执行 setId() 方法 \ No newline at end of file