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
parent
commit
8875f9f789
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 7
      modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionStore.cs

7
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}");

Loading…
Cancel
Save