feat: Spring Boot 整合 Spring Cache 和 Redis 缓存

This commit is contained in:
haoxr
2023-12-04 21:39:12 +08:00
parent 0fa99a61ae
commit e28b3e9490
12 changed files with 176 additions and 35 deletions

View File

@@ -30,6 +30,14 @@ spring:
max-idle: 8
# 连接池中的最小空闲连接 默认0
min-idle: 0
cache:
# 缓存类型 redis、none(不使用缓存)
type: redis
# 缓存时间(单位ms)
redis:
time-to-live: 3600000
# 缓存null值防止缓存穿透
cache-null-values: true
mybatis-plus:
global-config:
db-config:

View File

@@ -30,6 +30,14 @@ spring:
max-idle: 8
# 连接池中的最小空闲连接 默认0
min-idle: 0
cache:
# 缓存类型 redis、none(不使用缓存)
type: redis
# 缓存时间(单位ms)
redis:
time-to-live: 3600000
# 缓存null值防止缓存穿透
cache-null-values: true
mybatis-plus:
global-config:
db-config:

View File

@@ -30,7 +30,7 @@
t3.perm
FROM
`sys_role_menu` t1
INNER JOIN sys_role t2 ON t1.role_id = t2.id
INNER JOIN sys_role t2 ON t1.role_id = t2.id AND t2.deleted = 0
INNER JOIN sys_menu t3 ON t1.menu_id = t3.id
WHERE
type = '${@com.youlai.system.common.enums.MenuTypeEnum@BUTTON.getValue()}'

View File

@@ -13,4 +13,17 @@
WHERE
user_id = #{userId}
</select>
<!-- 统计角色下绑定的用户数量 -->
<select id="countUsersForRole" resultType="java.lang.Integer">
SELECT
count(*)
FROM
sys_user_role t1
INNER JOIN sys_role t2 ON t1.role_id = t2.id AND t2.deleted = 0
INNER JOIN sys_user t3 ON t1.user_id = t3.id
AND t3.deleted = 0
WHERE
t1.role_id = #{roleId}
</select>
</mapper>