🐛 Fix permission control

This commit is contained in:
2025-05-25 20:36:42 +08:00
parent 33767a6d7f
commit cfe29f5def
2 changed files with 28 additions and 10 deletions

View File

@ -43,6 +43,11 @@ public interface ICacheService
/// Gets a value from the cache
/// </summary>
Task<T?> GetAsync<T>(string key);
/// <summary>
/// Get a value from the cache with the found status
/// </summary>
Task<(bool found, T? value)> GetAsyncWithStatus<T>(string key);
/// <summary>
/// Removes a specific key from the cache
@ -231,6 +236,20 @@ public class CacheServiceRedis : ICacheService
return JsonConvert.DeserializeObject<T>(value!, _serializerSettings);
}
public async Task<(bool found, T? value)> GetAsyncWithStatus<T>(string key)
{
if (string.IsNullOrEmpty(key))
throw new ArgumentException("Key cannot be null or empty", nameof(key));
var value = await _database.StringGetAsync(key);
if (value.IsNullOrEmpty)
return (false, default);
// For NodaTime serialization, use the configured serializer settings
return (true, JsonConvert.DeserializeObject<T>(value!, _serializerSettings));
}
public async Task<bool> RemoveAsync(string key)
{
if (string.IsNullOrEmpty(key))