feat(#IYJPV): AppHelper 增加缓存
#Issue close https://gitee.com/LongbowEnterprise/dashboard/issues?id=IYJPV
This commit is contained in:
parent
ea2fe0f536
commit
63798634a8
|
@ -5,7 +5,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Bootstrap.Security.DataAccess" Version="2.2.5" />
|
||||
<PackageReference Include="Bootstrap.Security.DataAccess" Version="2.2.6" />
|
||||
<PackageReference Include="Longbow.Data" Version="2.3.2" />
|
||||
<PackageReference Include="Longbow.Logging" Version="2.2.8" />
|
||||
<PackageReference Include="Longbow.Security.Cryptography" Version="1.3.0" />
|
||||
|
|
|
@ -74,10 +74,8 @@ namespace Bootstrap.DataAccess
|
|||
}
|
||||
if (appIds != null)
|
||||
{
|
||||
appIds.ToList().ForEach(id =>
|
||||
{
|
||||
cacheKeys.Add(string.Format("{0}-{1}", AppHelper.RetrieveAppsByRoleIdDataKey, id));
|
||||
});
|
||||
cacheKeys.Add("AppHelper-RetrieveAppsBy*");
|
||||
corsKeys.Add("AppHelper-RetrieveAppsBy*");
|
||||
}
|
||||
if (dictIds != null)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Longbow.Cache;
|
||||
using Bootstrap.Security.DataAccess;
|
||||
using Longbow.Cache;
|
||||
using Longbow.Data;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
@ -39,6 +40,6 @@ namespace Bootstrap.DataAccess
|
|||
/// </summary>
|
||||
/// <param name="userName"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<string> RetrievesByUserName(string userName) => DbContextManager.Create<App>().RetrievesByUserName(userName);
|
||||
public static IEnumerable<string> RetrievesByUserName(string userName) => CacheManager.GetOrAdd($"{DbHelper.RetrieveAppsByUserNameDataKey}-{userName}", key => DbContextManager.Create<App>().RetrievesByUserName(userName), DbHelper.RetrieveAppsByUserNameDataKey);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,8 +24,10 @@ namespace Bootstrap.DataAccess.SqlServer
|
|||
UserHelper.SaveByRoleId(roleId, new string[] { userId });
|
||||
Assert.NotEmpty(AppHelper.RetrievesByUserName("Admin"));
|
||||
|
||||
var apps = AppHelper.RetrievesByRoleId(roleId);
|
||||
roleId = RoleHelper.Retrieves().FirstOrDefault(r => r.RoleName == "Default").Id;
|
||||
userId = UserHelper.Retrieves().FirstOrDefault(u => u.UserName == "User").Id;
|
||||
UserHelper.SaveByRoleId(roleId, new string[] { userId });
|
||||
var apps = AppHelper.RetrievesByRoleId(roleId);
|
||||
AppHelper.SaveByRoleId(roleId, apps.Select(a => a.Id));
|
||||
Assert.NotEmpty(AppHelper.RetrievesByUserName("User"));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue