菜单缓存区分系统

This commit is contained in:
2025-07-25 18:14:39 +08:00
parent cf6fc7033a
commit 323a509136
+5 -5
View File
@@ -15,9 +15,9 @@ class PermService
} }
// 用户资源缓存key // 用户资源缓存key
protected static function cacheKey(int $userId): string protected static function cacheKey(int $userId, string $systemCode): string
{ {
return "user_resources_{$userId}"; return "user_resources_{$userId}_{$systemCode}";
} }
/** /**
@@ -25,7 +25,7 @@ class PermService
*/ */
public function getUserResources(int $userId, string $systemCode) public function getUserResources(int $userId, string $systemCode)
{ {
$cacheKey = self::cacheKey($userId); $cacheKey = self::cacheKey($userId, $systemCode);
$cached = Cache::get($cacheKey); $cached = Cache::get($cacheKey);
if ($cached !== null) { if ($cached !== null) {
return $cached; return $cached;
@@ -58,8 +58,8 @@ class PermService
/** /**
* 清除资源相关缓存 * 清除资源相关缓存
*/ */
public function clearCache(int $userId): void public function clearCache(int $userId, string $systemCode): void
{ {
Cache::delete(self::cacheKey($userId)); Cache::delete(self::cacheKey($userId, $systemCode));
} }
} }