🐛 Replace the serializer in cache service with newtonsoft json to solve JsonIgnore issue

This commit is contained in:
2025-05-24 18:29:20 +08:00
parent 460ce62452
commit 445e5d3705
7 changed files with 117 additions and 108 deletions

View File

@ -11,17 +11,17 @@ public class PermissionService(
ILogger<PermissionService> logger)
{
private static readonly TimeSpan CacheExpiration = TimeSpan.FromMinutes(1);
private const string PermCacheKeyPrefix = "Perm_";
private const string PermGroupCacheKeyPrefix = "PermCacheGroup_";
private const string PermissionGroupPrefix = "PermGroup_";
private static string _GetPermissionCacheKey(string actor, string area, string key) =>
private static string _GetPermissionCacheKey(string actor, string area, string key) =>
PermCacheKeyPrefix + actor + ":" + area + ":" + key;
private static string _GetGroupsCacheKey(string actor) =>
private static string _GetGroupsCacheKey(string actor) =>
PermGroupCacheKeyPrefix + actor;
private static string _GetPermissionGroupKey(string actor) =>
PermissionGroupPrefix + actor;
@ -68,8 +68,8 @@ public class PermissionService(
var result = permission is not null ? _DeserializePermissionValue<T>(permission.Value) : default;
await cache.SetWithGroupsAsync(cacheKey, result,
new[] { _GetPermissionGroupKey(actor) },
await cache.SetWithGroupsAsync(cacheKey, result,
[_GetPermissionGroupKey(actor)],
CacheExpiration);
return result;