init user token permission allowed when upgrade

This commit is contained in:
xiaomlove
2025-05-02 23:55:15 +07:00
parent 43b241d617
commit 578ec3a6fc
3 changed files with 17 additions and 6 deletions

View File

@@ -101,13 +101,15 @@ class Setting extends NexusModel
return $value;
}
public static function updateUserTokenPermissionAllowedCache(): void
public static function updateUserTokenPermissionAllowedCache(array $allowed = []): void
{
$redis = NexusDB::redis();
$key = self::USER_TOKEN_PERMISSION_ALLOWED_CACHE_KRY;
$redis->del($key);
//must not use cache
$allowed = self::getFromDb("permission.user_token_allowed");
if (empty($allowed)) {
$allowed = self::getFromDb("permission.user_token_allowed");
}
if (!empty($allowed)) {
$redis->sAdd($key, ...$allowed);
}