Browse Source
Optimize permission lookup in PermissionStore
Replaces repeated LINQ queries with a HashSet for permission name lookups, improving performance when filtering permissions by cache keys.
pull/23622/head
maliming
1 year ago
No known key found for this signature in database
GPG Key ID: A646B9CB645ECEA4
1 changed files with
5 additions and
2 deletions
-
modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionStore.cs
|
|
|
@ -1,4 +1,5 @@ |
|
|
|
using System.Collections.Generic; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Microsoft.Extensions.Logging; |
|
|
|
@ -175,8 +176,10 @@ public class PermissionStore : IPermissionStore, ITransientDependency |
|
|
|
{ |
|
|
|
using (PermissionGrantRepository.DisableTracking()) |
|
|
|
{ |
|
|
|
var permissionNames = new HashSet<string>(notCacheKeys.Select(GetPermissionNameFormCacheKeyOrNull)); |
|
|
|
var permissions = (await PermissionDefinitionManager.GetPermissionsAsync()) |
|
|
|
.Where(x => notCacheKeys.Any(k => GetPermissionNameFormCacheKeyOrNull(k) == x.Name)).ToList(); |
|
|
|
.Where(x => permissionNames.Contains(x.Name)) |
|
|
|
.ToList(); |
|
|
|
|
|
|
|
Logger.LogDebug($"Getting not cache granted permissions from the repository for this provider name,key: {providerName},{providerKey}"); |
|
|
|
|
|
|
|
|