mirror of
				https://github.com/continew-org/continew-admin.git
				synced 2025-10-31 00:57:13 +08:00 
			
		
		
		
	refactor: 优化部分缓存使用
This commit is contained in:
		| @@ -19,6 +19,7 @@ package top.continew.admin.system.service.impl; | ||||
| import cn.hutool.core.bean.BeanUtil; | ||||
| import cn.hutool.core.util.StrUtil; | ||||
| import com.alicp.jetcache.anno.CacheInvalidate; | ||||
| import com.alicp.jetcache.anno.CacheType; | ||||
| import com.alicp.jetcache.anno.Cached; | ||||
| import lombok.RequiredArgsConstructor; | ||||
| import org.springframework.stereotype.Service; | ||||
| @@ -79,7 +80,7 @@ public class MenuServiceImpl extends BaseServiceImpl<MenuMapper, MenuDO, MenuRes | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     @Cached(key = "'ALL'", name = CacheConstants.MENU_KEY_PREFIX) | ||||
|     @Cached(key = "'ALL'", name = CacheConstants.MENU_KEY_PREFIX, cacheType = CacheType.BOTH, syncLocal = true) | ||||
|     public List<MenuResp> listAll() { | ||||
|         return super.list(new MenuQuery(DisEnableStatusEnum.ENABLE.getValue()), null); | ||||
|     } | ||||
|   | ||||
| @@ -267,7 +267,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     @Cached(key = "#id", cacheType = CacheType.BOTH, name = CacheConstants.USER_KEY_PREFIX, syncLocal = true) | ||||
|     @Cached(key = "#id", name = CacheConstants.USER_KEY_PREFIX, cacheType = CacheType.BOTH, syncLocal = true) | ||||
|     public String getNicknameById(Long id) { | ||||
|         return baseMapper.selectNicknameById(id); | ||||
|     } | ||||
|   | ||||
| @@ -70,7 +70,7 @@ public class DashboardController { | ||||
|     @GetMapping("/access/trend/{days}") | ||||
|     @CachePenetrationProtect | ||||
|     @CacheRefresh(refresh = 7200) | ||||
|     @Cached(key = "#days", cacheType = CacheType.BOTH, name = CacheConstants.DASHBOARD_KEY_PREFIX, syncLocal = true) | ||||
|     @Cached(key = "#days", name = CacheConstants.DASHBOARD_KEY_PREFIX, cacheType = CacheType.BOTH, syncLocal = true) | ||||
|     public R<List<DashboardAccessTrendResp>> listAccessTrend(@PathVariable Integer days) { | ||||
|         ValidationUtils.throwIf(7 != days && 30 != days, "仅支持查询近 7/30 天访问趋势信息"); | ||||
|         return R.ok(dashboardService.listAccessTrend(days)); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user