fix cache

This commit is contained in:
2026-04-27 00:04:29 +08:00
parent a8c7a20a64
commit 106d3eec19
+2 -1
View File
@@ -15,6 +15,7 @@ public class SimApiCache(IDistributedCache cache)
/// <param name="options"></param> /// <param name="options"></param>
public void Set(string key, object value, DistributedCacheEntryOptions? options = null) public void Set(string key, object value, DistributedCacheEntryOptions? options = null)
{ {
SimApiError.ErrorWhenNull(value, 400, "缓存值不能为null");
if (options is not null) if (options is not null)
{ {
cache.SetString(Prefix + key, SimApiUtil.Json(value), options); cache.SetString(Prefix + key, SimApiUtil.Json(value), options);
@@ -51,7 +52,7 @@ public class SimApiCache(IDistributedCache cache)
/// <returns></returns> /// <returns></returns>
public string? Get(string key) public string? Get(string key)
{ {
return cache.GetString(Prefix + key); return Get<string>(Prefix + key);
} }
/// <summary> /// <summary>